Solved

SQL User list to include status

Posted on 2014-12-15
4
166 Views
Last Modified: 2014-12-15
I am looking to generate a list of all users in SQL that will include the SQL login name plus their current status(i.e. whether their SQL account is locked or not).
0
Comment
Question by:rwheeler23
  • 2
4 Comments
 
LVL 24

Assisted Solution

by:Phillip Burton
Phillip Burton earned 250 total points
ID: 40500340
select [name], is_disabled from sys.server_principals
where type_desc = 'SQL_LOGIN'

Open in new window

0
 
LVL 45

Accepted Solution

by:
Vitor Montalvão earned 250 total points
ID: 40500351
You can try this query:
SELECT loginname, CASE LOGINPROPERTY(loginname,'IsLocked') 
						WHEN 0 THEN 'No'
						WHEN 1 THEN 'Yes'
						ELSE 'Domain User'
					END IsLocked
FROM sys.syslogins
WHERE hasaccess=1

Open in new window

0
 

Author Comment

by:rwheeler23
ID: 40500534
Thank you gentlemen, one script shows disabled logins and the other shows locked logins.
0
 

Author Closing Comment

by:rwheeler23
ID: 40500536
Thank you.
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Temporarily disable SQL Replication 7 21
MS SQL export CSV & schedule It 9 44
Help with SQL Query 23 39
How to calculate iops? 12 27
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
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.

757 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

20 Experts available now in Live!

Get 1:1 Help Now