Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Query/ Procedure to Generate list of logins and the DB access and their roles Expand / Collapse
Author
Message
Posted Friday, April 30, 2010 4:43 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, June 16, 2010 10:35 PM
Points: 6, Visits: 23
Hi All

I have requirement where i need to generate a list of users who can login into the sql server 2000 and what are all the database they can access and their roles. I got some information from this link

http://www.sqlservercentral.com/articles/Administration/listofdatabaseuserswithdatabaseroles/1545/

After executing this I got a list of all users and their database access and roles. Then I realized something was missing. I used to login to sql server 2000 and execute sql statements. I am local system admin. I can see a login named Builtin\Administrator under security and this has access to all database as db_public and db_owner.

Here i have 2 questions
1. Why is Builtin\administrators not listed ? doest that mean that the procedure and query given in the link is wrong.
2. I can see certain users who has access to few of the databases. But these users are not in the login section under security. How can a user have access to database without a login ?


I would be extremely thankfull to you could clarify my queries.

Thanks in advance
Rahul
Post #913568
Posted Friday, April 30, 2010 6:33 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Friday, August 29, 2014 7:44 AM
Points: 12,910, Visits: 32,015
i think it's due to the query; do a select * from sysusers in any database. there's no Builtin\Administrators in that list.

the query is not showing implicit users who have access regardless of whether you added them or not; those users like sa get access because they are sysadmins, they do not need to be added to each db's sysusers list. It's just getting explicitly granted users and their permissions.


Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #913621
Posted Monday, May 3, 2010 2:19 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, June 16, 2010 10:35 PM
Points: 6, Visits: 23
HI Lowell

Thanks a lot for your response. Whats the correct query to show all implicit users as well.

Thanking you
Rahul
Post #914526
Posted Thursday, October 31, 2013 9:19 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, August 28, 2014 6:56 AM
Points: 2, Visits: 88
If you found a solution for ...whats the correct query to show all implicit users as well...please post. Thanks
Post #1510258
Posted Thursday, October 31, 2013 10:08 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Friday, August 29, 2014 7:44 AM
Points: 12,910, Visits: 32,015
well, i'd start with implicit users that come from windows groups:
select * 
from master.sys.server_principals
where type_desc = 'WINDOWS_GROUP'

from there, for each name in the list, you can use a built in extended stored procedure which queries Active directory to enumerate all the users in the group
EXEC master..xp_logininfo 
@acctname = 'disney\authenticatedusers', --an example windows group, where my domain is "disney"
@option = 'members' -- show group members

EXEC master..xp_logininfo
@acctname = 'Builtin\Administrators',
@option = 'members' -- show group members



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1510300
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse