Solved

SQL User list to include status

Posted on 2014-12-15
4
178 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 48

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Solar Winds can't see SQL Server Express 17 38
Disable TLS1.0 on Win 2012 server 7 30
Casting is giving error in sql server 3 12
MS SQL + date 6 25
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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.
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…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

808 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