SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to identify GROUPS in database roles


How to identify GROUPS in database roles

Author
Message
Prasad Pavirala
Prasad Pavirala
SSC Journeyman
SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)

Group: General Forum Members
Points: 87 Visits: 12

Hi

I am writing these scripts to prepare report that shows all the users that have dbo rights on a given database.

By using sp_helprolemember 'db_owner' I can get the required list. But some of these members are Local or Domain groups. Under such situations, I have to show all the logins within these groups (iteratively if required). I can do that also by writing a VB script to read from Active directory.

But the main problem I am having here is how to identify if a dbo role member is a group or just a login?

Is there some table/view/stored proc that can give us this info?

Thanks

Prasad


Prasad Pavirala
Prasad Pavirala
SSC Journeyman
SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)

Group: General Forum Members
Points: 87 Visits: 12

Nevermind. I got it.

I am now using sp_helpuser, so that I can get both database user and login.

After that I can use isntgroup column in sysusers table to find which one of these account are actually groups.

Thanks!


K. Brian Kelley
K. Brian Kelley
Keeper of the Duck
Keeper of the Duck (25K reputation)

Group: Moderators
Points: 25236 Visits: 1917
I hadn't seen your post when I wrote the blog entry, so it's a nice coincidence. If you want to get everything in one query, you can query the sysusers and syslogins tables directly with a join.

Determining if it's a SQL login, Windows Login, or Windows group

K. Brian Kelley
@‌kbriankelley
hawg
hawg
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1616 Visits: 859

If you want to get the accounts that are in those groups, you can use the xp_logininfo command. Use it in the following manner:

EXEC master..xp_logininfo 'DOMAIN\Group', @option = 'members'

Good luck!



----------------------------------------------------------

01010011010100010100110000100000010100110110010101110010011101100110010101110010
001000000101001001101111011000110110101101110011
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search