[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
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
Medium Priority
?
292 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Suggested Courses

834 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