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
284 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Return 0 on SQL count 24 30
Help in Bulk Insert 9 38
Insert query into temp tables using Coldfusion 3 23
SSIS Feed MS SQL Server Stored procedure with loop 4 8
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

825 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