Friday, February 17, 2012

Determining windows grouop membership of a SQL login

Hello,
I'm trying to determine the windows group membership of a SQL login I've
created from a Windows login. Specifically, I'm trying to determine if the
login is in BUILTIN\Administrators or otherwise has admin permissions. For
example,
CREATE LOGIN <login> FROM WINDOWS WITH DEFAULT_DATABASE <database>
USE <database>
CREATE USER <login>
The CREATE USER call will fail if the login has admin privs because they
already have access under 'dbo'. So how do I go about determining the
membership of this login? sp_helplogins, sp_helpuser, sp_helpgroup don't
seem to provide the information I need.
Suggestions?
KeithKeith,
You could check with: is_srvrolemember ('sysadmin','Domain\Loginame')
RLF
"Keith" <keith@.alh.com> wrote in message
news:uBrsCyq2HHA.2752@.TK2MSFTNGP06.phx.gbl...
> Hello,
> I'm trying to determine the windows group membership of a SQL login I've
> created from a Windows login. Specifically, I'm trying to determine if
> the login is in BUILTIN\Administrators or otherwise has admin permissions.
> For example,
> CREATE LOGIN <login> FROM WINDOWS WITH DEFAULT_DATABASE <database>
> USE <database>
> CREATE USER <login>
> The CREATE USER call will fail if the login has admin privs because they
> already have access under 'dbo'. So how do I go about determining the
> membership of this login? sp_helplogins, sp_helpuser, sp_helpgroup don't
> seem to provide the information I need.
> Suggestions?
> Keith
>|||Thanks Russell! That seems to do the trick!
"Russell Fields" <russellfields@.nomail.com> wrote in message
news:O5C3HQr2HHA.5796@.TK2MSFTNGP05.phx.gbl...
> Keith,
> You could check with: is_srvrolemember ('sysadmin','Domain\Loginame')
> RLF
> "Keith" <keith@.alh.com> wrote in message
> news:uBrsCyq2HHA.2752@.TK2MSFTNGP06.phx.gbl...
>

No comments:

Post a Comment