?
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
?
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

777 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