SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Checking Admin User - Stored procedure


Checking Admin User - Stored procedure

Author
Message
shamshudheen
shamshudheen
SSC-Addicted
SSC-Addicted (474 reputation)SSC-Addicted (474 reputation)SSC-Addicted (474 reputation)SSC-Addicted (474 reputation)SSC-Addicted (474 reputation)SSC-Addicted (474 reputation)SSC-Addicted (474 reputation)SSC-Addicted (474 reputation)

Group: General Forum Members
Points: 474 Visits: 211
Hi

In my application , i am veryfying the Given user has administration rights in MS SQL SERVER 200 or not

please see the following stored procedure which i created, any body tell me whether this method is sufficient to verify the admin user in sql server 2000, since i not sure and don't find much information about verifying admin users in net . any body has idea please let me knos

ALTER PROCEDURE ISADMINUSER ( @UserName VARCHAR(100), @IsAdmin BIT OUTPUT )
AS
BEGIN
DECLARE @dbaccess BIT
,@islogin BIT
,@issysadmin BIT

SELECT @dbaccess = hasdbaccess
,@islogin = islogin
FROM master.dbo.sysusers
WHERE name = LTRIM(RTRIM(@UserName))

IF (@dbaccess = 1) AND (@islogin = 1)
BEGIN
SELECT @issysadmin = sysadmin
FROM master.dbo.syslogins
WHERE name = LTRIM(RTRIM(@UserName))
IF @issysadmin = 1
BEGIN
SET @IsAdmin = 1
RETURN
END
ELSE
BEGIN
SET @IsAdmin = 0
RETURN
END

END
ELSE
BEGIN
SET @IsAdmin = 0
RETURN
END
END



Thanks in Advance
Wildcat
Wildcat
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1237 Visits: 1444
Can you use "IS_SRVROLEMEMBER" function? (Check Book Online for the detailed info.)
shamshudheen
shamshudheen
SSC-Addicted
SSC-Addicted (474 reputation)SSC-Addicted (474 reputation)SSC-Addicted (474 reputation)SSC-Addicted (474 reputation)SSC-Addicted (474 reputation)SSC-Addicted (474 reputation)SSC-Addicted (474 reputation)SSC-Addicted (474 reputation)

Group: General Forum Members
Points: 474 Visits: 211
Thanks
IS_SRVROLEMEMBER function is working

thanks once again
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search