Query/ Procedure to Generate list of logins and the DB access and their roles

  • 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

  • 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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • HI Lowell

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

    Thanking you

    Rahul

  • If you found a solution for ...whats the correct query to show all implicit users as well...please post. Thanks

  • 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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply