本文是对 2009 年发布的《Account Lockout Tools》一文的现代化重写。虽然十几年过去了,微软的 ALTools 套件在本地 AD 环境中依然能打,但随着 Windows 版本的更迭和云身份(Entra ID)的普及,我们的排查思路需要升级。
当用户抱怨“我的账号又锁了”时,问题通常不是用户真的输错了密码,而在某个被遗忘的角落——一台旧手机、一个测试脚本、或者一个服务账号正在疯狂重试旧密码。
本文将介绍如何在现代混合环境中,结合经典工具与现代日志手段,快速定位锁定源头。
第一部分:经典的 ALTools 还能用吗?
微软官方的 Account Lockout and Management Tools (ALTools.exe) 尽管年代久远,但其中几个工具在排查本地 Active Directory(AD DS)问题时依然是神器。
1. LockoutStatus.exe (推荐保留)
这是套件里最直观的工具。它能列出域内所有域控(DC)上目标账号的状态。
- 核心价值:一眼看出是哪台 DC 判定了锁定(Orig Lock),以及 badPwdCount(坏密码计数)在各台 DC 上的分布。
- 现代替代:虽然 PowerShell 可以做到,但图形化的 LockoutStatus 在处理多站点复制延迟问题时依然最高效。
2. ALockout.dll (慎用)
原文中提到的这个 DLL 是一个“内核级”调试工具,它通过拦截认证调用来记录日志。
- 2025 警告:极不推荐在现代生产环境(尤其是 Exchange Server 或关键业务服务器)上安装此 DLL。它可能导致服务崩溃或启动失败。
- 替代方案:使用 Windows 原生的高级安全审计策略(Advanced Audit Policy),配合事件查看器即可,无需注入 DLL。
3. AcctInfo.dll (可选)
它给 AD 用户属性页增加了一个 “Additional Account Info” 标签。
- 现状:现代版本的“Active Directory 用户和计算机 (ADUC)”配合“属性编辑器 (Attribute Editor)”已能查看大部分信息(如
badPwdCount,lockoutTime),但 AcctInfo 的“在用户所在站点 DC 重置密码”功能依然方便。
第二部分:现代排查的核心——从 Netlogon 到事件 ID
在 Windows 2000/2003 时代,我们需要 grep Netlogon 日志或寻找事件 644/529。在 Windows Server 2008 之后的系统中(包括 Server 2019/2022),事件 ID 发生了变化,这是排查的关键。
关键事件 ID 对照表
| 事件类型 | 旧 ID (2003) | 新 ID (现代) | 关注字段 |
|---|---|---|---|
| 用户账号被锁定 | 644 | 4740 | Caller Computer Name (最关键,直接告诉你来源) |
| 登录失败 | 529/530… | 4625 | Failure Reason, IP Address, Logon Type |
现代排查三步走
- 定位锁定时间与来源 (4740)
- 在 PDC 仿真器角色的域控上,打开事件查看器,筛选 Security 日志中的 ID 4740。
- 查看详情中的
Caller Computer Name。如果不为空,恭喜你,你已经找到了发起攻击的机器。
- 分析登录类型 (4625)
- 登录到那台“来源机器”,筛选 Security 日志中的 ID 4625。
- 查看
Logon Type(登录类型):- Type 2: 交互式登录(有人在键盘前尝试)。
- Type 3: 网络登录(映射驱动器、访问共享)。
- Type 4: 批处理(计划任务)。
- Type 5: 服务启动。
- 使用 PowerShell 自动化
不想逐台翻日志?使用 PowerShell 快速搜索 PDC 上的锁定事件:powershell# 在域控上运行,查找最近24小时的锁定事件 Get-WinEvent -FilterHashtable @{LogName='Security';ID=4740;StartTime=(Get-Date).AddHours(-24)} | Select-Object TimeCreated, @{N='User';E={$_.Properties[0].Value}}, @{N='SourceComputer';E={$_.Properties[1].Value}}
第三部分:混合云环境下的新挑战 (Entra ID)
如果你的环境同步了 Microsoft Entra ID (原 Azure AD),情况会变得复杂一点。
1. 本地锁定 vs 云端锁定
- Write-back(回写):如果你开启了密码回写,云端的锁定状态可能会同步回本地。
- Smart Lockout(智能锁定):Entra ID 拥有一套独立的“智能锁定”机制。它能区分攻击者和合法用户。攻击者的 IP 会被云端直接拦截,而用户可能感觉不到。
- 排查差异:如果是云端触发的锁定,本地 DC 的日志可能看不出端倪。你需要去 Entra Admin Center 查看 Sign-in logs(登录日志)。
2. 常见“云”误报源
- 旧手机/平板:用户修改了域密码,但个人的 iPad 上的邮件客户端还存着旧密码,不断尝试连接 Exchange Online,最终导致本地账号被锁。
- Azure AD Connect:同步服务本身的账号问题。
第四部分:终极排查清单 (Checklist)
当工具显示来源是某台特定机器,但你找不到原因时,请按此清单逐一检查:
- [ ] 凭据管理器 (Credential Manager):控制面板中存储的旧 Windows 凭据。
- [ ] 映射网络驱动器:使用了“连接时使用不同凭据”选项创建的驱动器。
- [ ] 计划任务:这是最常见的元凶,检查是否有任务配置了过期的密码。
- [ ] Windows 服务:运行在特定用户身份下的服务。
- [ ] RDP 会话:用户断开(Disconnect)而非注销(Log off)了远程桌面,后台程序仍在运行。
- [ ] 移动设备 (ActiveSync):检查 Exchange 日志,看是否有特定 Device ID 频繁报错。
- [ ] 脚本/代码:硬编码在配置文件或脚本中的密码。
推荐工具与阅读
虽然 ALTools 老旧,但其思路永不过时。建议结合以下官方资源进行排查:
- Account Lockout and Management Tools (Microsoft) – ALTools 官方下载页。
- Troubleshoot account lockout in Microsoft Entra Domain Services (Microsoft Learn) – 云托管域环境下的锁定排查。
- 4740(S) A user account was locked out (Microsoft Learn) – 详解 4740 事件字段含义。
- 4625(F) An account failed to log on (Microsoft Learn) – 详解 4625 登录失败原因代码。





Email –
comments – I am really happy with your blog because your article is very unique and powerful for new reader.
Thanks!
Have you ever heard of a problem where the Lotus Connection web based feed client tries to authenticate to a sharepoint feed using LC credentials?
I’m trying to find out how LC handles authenticated SP blogs. If it in fact tries to repeatedly authenticate with Lotus Connection credentials that would have caused my lockout scenario.
I’ve been suffering from recurrent account lockouts that our IT group has been unable to diagnose.
Are there any XP client programs I can install on my own machine to inspect all authentication issues? I could then, at least to my own satisfaction, determine if my machine was really making the authentication requests and, if it was, figure out the source.
I’ve subscribed to the comment feed here if you can reply in comments. Or you can use the email address I’ve provided here if you’d like.
Very much appreciated!
Thanks!
AcctInfo.dll can be installed on client side to log bad password. but I have to say it’s not helpful at most of time. bad password may come from other source.
So I still suggest you to contact IT group to find clue from server side. also you can check if some services is started up by your account via services.msc command