Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/144810-solved-user-rolls/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/144810-solved-user-rolls/#findComment-760020
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/144810-solved-user-rolls/#findComment-760022
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.