Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Does anyone know how to determine if a connected session is a Windows Domain Admin? Thanks

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-11-19 : 08:29:42
Joe writes "I tried to hack it with sth like

DBCC CHECKTABLE ('sysusers')

This would fail if user is not a member of the sysadmin fixed server role or the db_owner fixed database role, or the 'sysusers' table owner, and are not transferable.

Are there cases where this will not work?
Is there any other choice available?

Before using DBCC CHECKTABLE, I also tried the following query but it only works with normal login:

SELECT COUNT(*) FROM master..syslogins WHERE (name = SYSTEM_USER OR loginname = SYSTEM_USER) AND sysadmin = '1'

Thanks!

Joe"

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-11-19 : 12:19:02
Windows domain admin? SQL Server doesn't know about this kind of information. It grants sysadmin access if the account is a member of the local admin group. But anyone can be a member of that group including domain admins. If you need this information, then I suggest writing code outside of SQL Server and make calls to the ADS API.

Tara
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-11-19 : 21:15:40
You might be able to call:

EXEC master..xp_cmdshell 'net group "Domain Administrators" /domain'

And get that information. I'm not sure if "Domain Administrators" is the correct group name, replace it with the correct one if it's wrong. You can find out more about "net group" in the Windows help file.
Go to Top of Page
   

- Advertisement -