Solved

SQL User list to include status

Posted on 2014-12-15
4
183 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
[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
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 50

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tempdb Contention - SQL SERVER 10 37
Http Post send by Store Procedure Help 5 22
SQL - Subquery in WHERE section 4 27
SQL query 45 31
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

738 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