Re: Check User in Role?

From: Partha Mandayam (mcp111_at_hotmail.com)
Date: 08/26/04


Date: Thu, 26 Aug 2004 12:02:08 -0700

use IS_SRVROLEMEMBER.

IF IS_SRVROLEMEMBER ('sysadmin') = 1
   print 'Current user''s login is a member of the sysadmin role'
ELSE IF IS_SRVROLEMEMBER ('sysadmin') = 0
   print 'Current user''s login is NOT a member of the sysadmin role'
ELSE IF IS_SRVROLEMEMBER ('sysadmin') IS NULL
   print 'ERROR: Invalid server role specified'

Regards

Partha Mandayam
Software Consultant
Home page: http://partha.tripod.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Relevant Pages

  • Re: how to find out if a domain user is in the sysadmin server role?
    ... I connected with a login that is a member of a group that is a sysadmin. ... print 'Current user''s login is NOT a member of the sysadmin role' ...
    (microsoft.public.sqlserver.security)
  • Re: Other way of Changing Password if does not have Server Role
    ... A user can change his password without being a member of the sysadmin role. ... You just have to login as the user and then omit the 3rd parameter ... Dejan Sarka, SQL Server MVP ...
    (microsoft.public.sqlserver.security)
  • Re: sp_change_users_login use after restore
    ... The user was a member of the sysadmin role, once I took the role out, ... In that case the login will will be 'dbo' in the ... > SQL Server MVP ...
    (microsoft.public.sqlserver.security)
  • RE: cannot log into Reporting Services from SMSS
    ... When you say in SMSS select Server name...Server roles, ... "sysadmin" role was already checked for that login. ... I installed the ReportServer as part of a full installation of SQL Server ... Please add a domain user as a new login and grant it sysadmin role. ...
    (microsoft.public.sqlserver.connect)
  • Re: losing sysadmin
    ... >login as SA. ... >> 1)My SQL Server is in Mixed Authentication Mode. ... >> 4)Now I changed the Mixed Authentication Mode to Windows ... >> now I don't have a sysadmin role. ...
    (microsoft.public.sqlserver.security)