Results 1 to 7 of 7

Thread: SP Listing all users with access to a DB????

  1. #1
    Join Date
    May 2005
    Posts
    111

    SP Listing all users with access to a DB????

    i'm looking for an SP or any script that list all of the logins that have access to a specific Database. IMPORTANT. not all of the users listed in a database, but logins that have actual permission to a given database. We move are databases around and have several orphaned users with said database. I could care less about a user unless they exist in the master DB. -Allen

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You can query sysprotects table.

    To get orphaned users you can use

    sp_change_users_login 'report'

  3. #3
    Join Date
    May 2005
    Posts
    111
    thanks, for the reply. however, sysprotects does not list user logins nor does it list db names. probably need to join with other system tables.

    also, not interested in orphaned users--looking for non-orphaned users with access to a specific database.

  4. #4
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Are you looking for this

    select * from sysusers as su
    join master..syslogins as sl
    on su.sid = sl.sid

  5. #5
    Join Date
    May 2005
    Posts
    111
    that's the ticket--thank you!

  6. #6
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254

  7. #7
    Join Date
    Sep 2002
    Posts
    5,938
    sp_helplogins

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •