Advertisements

SQL-BOX.COM

–SQL Server Storage

HOW TO CHECK IF A USER ACCOUNT IS LOCKED? IF LOCKED HOW TO UNLOCK IT?

There are times a DBA gets a request to see the user account got locked or the user is unable to login.

Here is the simple script to see if a login account is locked or not.

Use Master
Go
select loginproperty('UserName','Islocked')
GO

If  the script above returns

1- Account got Locked

0- Not Locked

If Retuns 1 and need to Unlock the account Run the below script.

ALTER LOGIN [UserName] WITHPASSWORD='****'UNLOCK;
GO

 

 

 

 

 

 

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: