snippetsqlMinor
How do I identify all super users in SQL Server?
Viewed 0 times
allsqlsuperidentifyhowserverusers
Problem
For a security audit,I need to identify all super users and log every activity performed. Best approach for this?
By "super user" I mean sysadmin, serveradmin, securityadmin, processadmin, and dbcreator.
By "super user" I mean sysadmin, serveradmin, securityadmin, processadmin, and dbcreator.
Solution
You can use this code:
You would also need to check for the
SELECT name,type_desc,is_disabled,
(IS_SRVROLEMEMBER ('sysadmin',name)) AS ISSRVROLE
FROM master.sys.server_principals
-- WHERE IS_SRVROLEMEMBER ('sysadmin',name) = 1
ORDER BY name ;sys.server_principals - Contains a row for every server-level principalIS_SRVROLEMEMBER - Indicates whether a SQL Server login is a member of the specified server role.You would also need to check for the
sysadmin-equivalent CONTROL SERVER permission for the server principal in sys.server_permissions.IS_SRVROLEMEMBER can return:- 0 - login is not a member of role.
- 1 - login is a member of role.
- NULL - role or login is not valid, or you do not have permission to view the role membership.
Code Snippets
SELECT name,type_desc,is_disabled,
(IS_SRVROLEMEMBER ('sysadmin',name)) AS ISSRVROLE
FROM master.sys.server_principals
-- WHERE IS_SRVROLEMEMBER ('sysadmin',name) = 1
ORDER BY name ;Context
StackExchange Database Administrators Q#193819, answer score: 8
Revisions (0)
No revisions yet.