Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

which logins are locked?

i could see anything like 'islocked' columns in any of the system views?

could you write   a query that will quickly tell if any login is locked out in the sql server instance?

thanks
0
25112
Asked:
25112
  • 2
2 Solutions
 
pateljituCommented:
Please refer to this blog, here is the code sample:
 /*
This script is designed to find the logins those are locked out in the database Server.
It is tested to run on:
SQL 2000 - NO (Login lock feature was not introduced in this SQL version)
SQL 2005 - YES
SQL 2008 - YES
*/
set nocount on
declare  Cur_locked_login cursor for select name from master..syslogins order by name
declare @loginname nvarchar(100)
open Cur_locked_login
fetch next from Cur_locked_login into @loginname
while @@FETCH_STATUS >= 0
begin
if (select LOGINPROPERTY(@loginname,'islocked')) =1
print 'Login -> ' + @loginname +' is LOCKED'
fetch next from Cur_locked_login into @loginname
end
close Cur_locked_login
deallocate Cur_locked_login

Open in new window


http://dbasearch.blogspot.ca/2011/10/sql-login-locked-out-status-check.html
0
 
Tapan PattanaikSenior EngineerCommented:
Hi 25112 ,

Please check this query.

select * from sys.server_principals
where is_disabled = 1
0
 
Tapan PattanaikSenior EngineerCommented:
SELECT LOGINPROPERTY('UserName', 'IsLocked')
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now