Solved

Query to display user and all permissions associated?

Posted on 2012-04-09
2
343 Views
Last Modified: 2012-04-17
Hello,

I am looking for a query that displays every user and his or hers associated permissions as well as associated server roles. Thank you in advance. . .
0
Comment
Question by:fstinc
2 Comments
 
LVL 7

Accepted Solution

by:
Anoo S Pillai earned 500 total points
ID: 37826072
I believe you are looking for two queries :) , Please see the following queries, which will be useful to you.

-- Object level permissions
SELECT      Obj.name ,Perm.permission_name , Principal.Name
FROM      sys.database_permissions      Perm
JOIN      sys.database_principals      Principal
ON      Perm.grantee_principal_id = Principal.principal_id
JOIN      (SELECT DISTINCT(id) ObjID FROM sys.syspermissions WHERE id > 0) AS SysPerm
ON      SysPerm.ObjID = Perm.major_id
JOIN      sys.sysobjects Obj
ON      Obj.id = SysPerm.objid
WHERE      Perm.major_id = SysPerm.ObjID

-- Role member ship

SELECT      ROLE.[name] Role ,  Principal.[name] Principal
FROM      sys.database_role_members ROLEMEMBER
JOIN      sys.database_principals as ROLE
ON            ROLEMEMBER.role_principal_id = ROLE.principal_id
JOIN      sys.database_principals as PRINCIPAL
ON            ROLEMEMBER.member_principal_id = PRINCIPAL.principal_id

Hope this is helpful.
0
 

Author Comment

by:fstinc
ID: 37858318
Thank you!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sql query help 7 96
Compare data between two databases 16 95
What is the best way to calculate hours worked 5 61
Insert from Stored Procedure where some field/s > 0 7 43
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now