June 10, 2008 at 2:28 am
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
,@issysadminBIT
SELECT @dbaccess = hasdbaccess
,@islogin = islogin
FROM master.dbo.sysusers
WHEREname = 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
June 10, 2008 at 10:15 am
Can you use "IS_SRVROLEMEMBER" function? (Check Book Online for the detailed info.)
June 10, 2008 at 9:51 pm
Thanks
IS_SRVROLEMEMBER function is working
thanks once again
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply