Solved

How can I get all the user id's, NT Auth and SQL Auth used on a server by database

Posted on 2006-07-12
6
282 Views
Last Modified: 2006-11-18
I have a SQL Server 2000.

I need to know how I can get all the user id's, both NT Auth and SQL Auth, so I can build an emailing list for process status notification.

Thank you,
Sami
0
Comment
Question by:tf842
  • 2
  • 2
  • 2
6 Comments
 
LVL 12

Expert Comment

by:Einstine98
ID: 17094314
select * from sysusers
0
 

Author Comment

by:tf842
ID: 17094429
Do I have to query sysusers for each database on the server or is there a centralized table that will give me the userid and the databases they have permission to access?

I was hoping something could be queried from the Security.logins for the server and joined to the permissions so the permissions to the individual databases could be identified.

I apologize for this extension of the question, but I was in a hurry and submitted it too quickly. I will increase the points to 500 should the answer include this additional part of the question.

Sami

0
 
LVL 12

Expert Comment

by:Einstine98
ID: 17094465
no worries...

sysusers is for each database... you can write a script to query all the databases for you

SELECT 'UNION SELECT * FROM [' + NAME + ']..sysusers'
FROM sysdatabases

copy the outcome, paste it in a new query, delete the first uninon and you have all the users in all databases...

you can then join it to

master..syslogins

0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 250 total points
ID: 17096278
somethinng like this

exec sp_MSforeachDB 'use ? ;
select ''?'' DB,sl.Name from sysusers  su
inner join master..syslogins sl
on sl.sid = su.sid
where sl.isNtName = 1 '

0
 

Author Comment

by:tf842
ID: 17193569
aneeshattingal,
I tried to make your code work to no avail. I can get a successful message if I run just:
exec sp_MSforeachDB 'use ?' ; (with the added tick after the ?

However, the balance of the query does not run properly with or without the above portion.

Any ideas?

Thank you,
Sami
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17194045
you need to run the Query as it is no need to change, just copy paste and run
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now