18 September,2012 by Tom Collins
This query returns all the database users and roles attached.
The sys.database_principals returns a role for each principal in the database. The sys.database_role_members returns a row for each member in a role.
As well as giving a good overview of Database Roles the query is useful for auditing SQL Security Policy. A common policy may be to disallow certain roles – such as db_owner to be used.
SELECT members.name, roles.name,roles.type_desc,members.type_desc FROM sys.database_role_members rolemem INNER JOIN sys.database_principals roles ON rolemem.role_principal_id = roles.principal_id INNER JOIN sys.database_principals members ON rolemem.member_principal_id = members.principal_id ORDER BY members.name
SQL Server – How to manage Failed Logon attempts
SQL Server - Security Risk Analysis and database security
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |