Brian W Posted February 11, 2009 Share Posted February 11, 2009 I'm working on a php tool to convert mysql tables over to mssql. I have that part working pretty well (l can attach the source if anyone wants to play with it). My problem is that I'm trying to add another tool that will allow you to create new Databases in MsSQl without going into the "SQL Server Management Studio". This also works but only when the "login" that the user has specified has permission to create a Database, other wise it feeds me an error message that most (but not all) people will understand. So, in an attempted to make this application marketable (gnu, but still), I want to tell the user whether or not the login being used can has the permissions needed to create a database. Does any one have an idea of how to do this? What I tried: $sql = "sp_displaylogin ".$_SESSION['Ms_Username']; I was just going to get the list on information, if it were the right information, and filter though it but I get the message: Could not find stored procedure 'sp_displaylogin' So, please help me with what I have or tell me a better idea please. Quote Link to comment https://forums.phpfreaks.com/topic/144810-solved-user-rolls/ Share on other sites More sharing options...
Brian W Posted February 11, 2009 Author Share Posted February 11, 2009 I realize that I spelled "roles" as "rolls". Quote Link to comment https://forums.phpfreaks.com/topic/144810-solved-user-rolls/#findComment-759924 Share on other sites More sharing options...
corbin Posted February 11, 2009 Share Posted February 11, 2009 Is that a built in SP? If so, it will probably be in the master database. Is that the database you have selected? Quote Link to comment https://forums.phpfreaks.com/topic/144810-solved-user-rolls/#findComment-760011 Share on other sites More sharing options...
Brian W Posted February 11, 2009 Author Share Posted February 11, 2009 I've gone through a lot today with this one. I've found many problems and very few solutions. What I'm messing with now is IS_SRVROLEMEMBER ('dbcreator') which seems to be exactly what I'm looking for today. But, I need it to return something for me to use. $query = mssql_query("IF IS_SRVROLEMEMBER ('dbcreator') = 1 print 'Current user''s login is a member of the dbcreator role'"); That is a mod from the example I found here http://msdn.microsoft.com/en-us/library/ms176015.aspx It does not return a "valid MS SQL-result resource" If I can have it return 1 if good, 2 or null if not, I'd be a happy camper... but I can't seem to figure out how to return the value. Quote Link to comment https://forums.phpfreaks.com/topic/144810-solved-user-rolls/#findComment-760020 Share on other sites More sharing options...
Brian W Posted February 11, 2009 Author Share Posted February 11, 2009 NVM... I guess it took me developing a complete thought in order to figure it out. I'm using: $sql = "IF IS_SRVROLEMEMBER ('dbcreator') = 1 print '1' ELSE print '2'"; $query = mssql_query($sql) or die("The login you are using does not have permission to view roles"); if(mssql_get_last_message() != 1){ echo "<span style=\"color:red; font-size:18px;\">MsSQL User may not create databases</span>"; } It seems to do what I need it to do. Thanks anyways guys. Quote Link to comment https://forums.phpfreaks.com/topic/144810-solved-user-rolls/#findComment-760022 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.