Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

See which roles users are in

Status
Not open for further replies.

LonnieJohnson

Programmer
Apr 16, 2001
2,628
0
0
US
How do I query the system tables to see all the roles a particular user name is associated with. I looked at the sysusers table and did not see what I needed.

Thanks in advance.

ProDev, MS Access Applications
Visit me at ==> Contact me at ==>lonniejohnson@prodev.us

May God bless you beyond your imagination!!!
 
Have you tried the master.dbo.syslogins table? It has a column for each SQL Server fixed role. If the value in the column is 1 then the login is a member of the corresponding role.
 
Maybe I don't understand too well.

I have created Roles in a database to put users in. So would I be able to query the dB for a user name to determine which of the roles that I created that user was in?

Thanks again.

ProDev, MS Access Applications
Visit me at ==> Contact me at ==>lonniejohnson@prodev.us

May God bless you beyond your imagination!!!
 
Try this query:

Code:
SELECT u.name AS username, r.name AS role
FROM sysusers u JOIN sysmembers m ON u.uid = m.memberuid
  JOIN sysusers r ON m.groupuid = r.uid
WHERE u.name = '<user>'

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top