Image Placeholder

Using SQL Server to Unlock Sitecore User Account


As a Sitecore developer, we need to interact with the Sitecore Admin a lot. Sometimes we might have the admin locked out after too many attempts for incorrect password input. Having to work locally, we can’t use the normal route of resetting our password via email. In this blog, we’ll dive into a solution that helps resolve this problem in our local environment by using Microsoft SQL management studio.

Using SQL Server to Unlock Sitecore User Account and Reset The Sitecore Admin Password To "b"

Follow the following steps to unlock your Sitecore User Account.

SQLUnlock_Sitecore 1b

Step 1

Go to your Sitecore DB by logging in to Microsoft SQL management studio and locate the instance’s name ending with “Core”, in my case, its “ClothingCo_Core”

SQLUnlock_Sitecore 1a

Step 2

Copy the following SQL script and run it within this  “ClothingCo_Core” DB. The account I want to unlock is admin2, so the username from the script is  “sitecore\Admin2”.

UPDATE  aspnet_Membership 
SET     IsLockedOut = 0, 
        FailedPasswordAttemptCount = 0
WHERE   UserId IN (SELECT UserId FROM aspnet_Users WHERE UserName = 'sitecore\Admin2')

The Sitecore account should be unlocked now after running the script, but if you don’t remember your password at all, what you can do is to reset the password to the default password “b” by using the following script for the same DB:

    [IsApproved] = '1', 
    [IsLockedOut] = '0'
    UserId IN (
        SELECT UserId FROM dbo.aspnet_Users WHERE UserName = 'sitecore\Admin2'