DEV Community

Bryz︱🦾
Bryz︱🦾

Posted on

🔒 Account Keeps Locking Out? Find the Source Before You Unlock It Again

"I'm typing the right password and it STILL locks me out!" 😤

Every help desk hears this. The quick fix is to unlock the account. Ten minutes later, it's locked again. 🔁

Here's the secret: the user usually is typing the right password. Some other device or app is still trying the old one in the background, and every failed try counts toward the lockout threshold.

Let's find it. 🕵️

🔍 Step 1: Confirm it's really a lockout

On a machine with the Active Directory PowerShell module (RSAT):

Get-ADUser jdoe -Properties LockedOut,LastBadPasswordAttempt,BadLogonCount |
  Select-Object Name,LockedOut,LastBadPasswordAttempt,BadLogonCount
Enter fullscreen mode Exit fullscreen mode

If LockedOut is True and LastBadPasswordAttempt keeps updating while the user isn't even signing in, something else is sending bad passwords.

🧭 Step 2: Find the caller computer

When an account locks, the domain controller logs Security event 4740. It includes the Caller Computer Name, which is the machine where the bad attempts came from.

Get-WinEvent -ComputerName DC01 -FilterHashtable @{LogName='Security'; Id=4740} -MaxEvents 20 |
  Where-Object { $_.Message -match 'jdoe' } |
  Select-Object TimeCreated, Message
Enter fullscreen mode Exit fullscreen mode

Tip: check the DC holding the PDC emulator role first (Get-ADDomain | Select PDCEmulator), since lockouts get forwarded there.

📱 Step 3: Hunt the usual suspects

Once you know the source machine (or even if it's blank), check:

  • 📱 Phone mail app still using the old password
  • 💻 A second laptop or old PC the user forgot about
  • 🗂️ A mapped drive saved with old credentials
  • ⏰ A scheduled task or service running as the user
  • 🖥️ A disconnected RDP session still signed in somewhere

🧹 Step 4: Clear stale credentials

On the source PC, list saved credentials:

cmdkey /list
Enter fullscreen mode Exit fullscreen mode

Delete the old ones:

cmdkey /delete:TargetName
Enter fullscreen mode Exit fullscreen mode

Or open Control Panel > Credential Manager > Windows Credentials and remove them there. Check mapped drives with net use, and update the password on the phone.

✅ Step 5: Unlock and watch

Unlock-ADAccount jdoe
Enter fullscreen mode Exit fullscreen mode

Then re-run the Step 1 command after a bit. If BadLogonCount stays low, you got it. 🎉

💡 The takeaway

Unlocking treats the symptom. Finding the device with the old password fixes the problem, and the user stops calling back.

What's the weirdest lockout source you've ever tracked down? Drop it below 👇

Top comments (0)