Re: how to find out if a domain user is in the sysadmin server role?
- From: "Rick Byham, \(MSFT\)" <rickbyh@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 21 Aug 2008 09:12:04 -0700
The example in Books Online works for me. I connected with a login that is a member of a group that is a sysadmin. The user has no individual login. The code:
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: The server role specified is not valid.'
Returns "Current user's login is a member of the sysadmin role."
Or if you are testing another user
EXECUTE AS LOGIN = 'DOMAIN\User';
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: The server role specified is not valid.'
--
Rick Byham (MSFT), SQL Server Books Online
This posting is provided "AS IS" with no warranties, and confers no rights.
"Shy Engelberg" <Shy Engelberg@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:4005638A-6F70-48CF-9EE7-C15B392580FB@xxxxxxxxxxxxxxxx
hi,
i am trying to find out using T-SQL if a domain user has sysdmin permssions.
i can use IS_SRVROLEMEMEBR, but if the user is not a login and directly
under the sysadmin role, this function will not help.
i need to know even if one of the domain or local groups the user is member
of has the sysadmin server role.
Example: if a user is a domain admin, he is a part of the server's local
admin group, which s a part of the BUILTIN\ADMINISTRATORS login, that has
sysadmin permissions.
Thanks,
Shy.
.
- Prev by Date: Re: SQL Server 2005 Windows Authentication - logon failure
- Next by Date: Re: sp_revoke login is not working as expected.
- Previous by thread: SQL Server 2005 Windows Authentication - logon failure
- Next by thread: Re: sp_revoke login is not working as expected.
- Index(es):
Relevant Pages
|