When it is written
AD FS writes 516 to the Security log of the AD FS server, under the event source AD FS Auditing, with the user, the client IP, the bad password count and the time of the last bad password. Microsoft's extranet lockout page lists it among the lockout events, which AD FS writes when a user reaches the lockout threshold and when it receives a sign-in attempt for a user who is already locked out. A 2015 Microsoft post on extranet lockout in AD FS for Windows Server 2012 R2 names the audit ExtranetLockoutAccountRestrictedAudit and assigns both cases to it: the first lockout, and each attempt while the observation window has not passed.
Extranet lockout covers only user name and password requests that come through the Web Application Proxy. With the original extranet lockout of Windows Server 2012 R2, AD FS reads the user's badPwdCount from the primary domain controller and refuses extranet requests once it reaches ExtranetLockoutThreshold, until ExtranetObservationWindow has passed since badPasswordTime. With Extranet Smart Lockout (Windows Server 2016 and later) AD FS keeps its own counts per familiar and unfamiliar location. Either way AD FS does not lock the account in Active Directory.
How to turn it on
AD FS Auditing writes the event to the AD FS auditing (Event Viewer > Windows Logs > Security (event source AD FS Auditing)), which is off by default. Microsoft
AD FS writes its audit events to the Security log of each AD FS server, with AD FS Auditing as the event source. Microsoft says these audit logs are not enabled by default; its Connect Health steps add that the two Federation Service check boxes should already be selected. Three settings must all be in place:
- The user right. The AD FS service account must hold Generate security audits (Local Security Policy > Security Settings > Local Policies > User Rights Assignment). Where AD FS runs on a domain controller, Microsoft points to the Default Domain Controllers Policy instead of the local policy.
- The audit subcategory. Audit Application Generated (Object Access) for success and failure, by Group Policy (Advanced Audit Policy Configuration > Audit Policies > Object Access) or locally with
auditpol. Microsoft warns that a Group Policy can turn AD FS auditing off. - The Federation Service audits. In AD FS Management, Edit Federation Service Properties > Events: Success audits and Failure audits. Connect Health's steps make this change on the primary server only, because it is a setting of the farm.
From Windows Server 2016 the farm also has an audit level, shown as AuditLevel by Get-AdfsProperties: Basic, the default, logs no more than five events per request and includes 1200 to 1203; Verbose logs every event, including 411, 412 and 501 (Microsoft's Connect Health tables); None logs nothing. Microsoft Defender for Identity and Connect Health ask for Verbose.
Audit every AD FS server of the farm, because each one logs only the requests it handled. The Web Application Proxy servers do not need auditing. The extranet lockout events (512, 515, 516, 1210) also need extranet lockout to be enabled; the check command below shows its settings.
auditpol /get /subcategory:"Application Generated"auditpol /get /subcategory:"{0CCE9222-69AE-11D9-BED3-505054503030}"auditpol /set /subcategory:"Application Generated" /success:enable /failure:enableGet-AdfsProperties | Format-List AuditLevel, LogLevel, EnableExtranetLockout, ExtranetLockoutMode, ExtranetLockoutThreshold, ExtranetObservationWindowSet-AdfsProperties -AuditLevel VerboseNeeds extranet lockout turned on (EnableExtranetLockout true; with Extranet Smart Lockout, in Log-Only or Enforce mode) and AD FS auditing reaching the Security log. Get-AdfsProperties shows the lockout settings. Microsoft's update list for AD FS in Windows Server 2012 R2 includes 3134787, for AD FS logs without the client IP address in account lockout scenarios.
Fields
The template of this event is not part of client Windows and Microsoft does not publish its XML field names, so the fields are named by the labels of Microsoft’s documentation.
| Field | What it holds |
|---|---|
| Activity ID | GUID that AD FS assigns to the request and logs in every event of it, in the audit, admin and debug logs. All zeros for legacy authentication proxied by Exchange Online. |
| User | The user who is locked out. Microsoft's lockout cmdlets (Get-ADFSAccountActivity, Reset-ADFSAccountLockout) take the user principal name; check which form your events carry. |
| Client IP | Address of the client of the request. Microsoft notes that it can be one of Microsoft's addresses when Exchange Online sends a legacy authentication request for the client. |
| Bad Password Count | Number of bad passwords counted for the user. With the original extranet lockout this is the badPwdCount that AD FS reads from the primary domain controller; with smart lockout, AD FS's own count. |
| Last Bad Password Attempt | Time of the user's most recent bad password, the start of the observation window. |
Values to know
Client IP
| Value | Meaning | Signal |
|---|---|---|
One address, lockouts for many users | A password spray from that addressA spray that came back often enough to pass the threshold for several accounts. | Attack signal |
The user's own usual address | A device of the user with an old passwordMicrosoft's troubleshooting suggests updating the credentials saved in the application or service. | Noise |
A Microsoft address | Legacy authentication through Exchange OnlineMicrosoft says the submitter is then in x-ms-forwarded-client-ip, not in this field. | Worth knowing |
Activity ID
| Value | Meaning | Signal |
|---|---|---|
00000000-0000-0000-0000-000000000000 | Legacy authenticationMicrosoft says legacy authentication through Exchange Online has this activity ID. | Worth knowing |
Volume and noise
Microsoft's password spray playbook names 516 as an extranet lockout indicator to collect. Outside an attack, lockouts come mostly from devices that keep submitting a user's old password: Microsoft's lockout troubleshooting names applications with cached credentials and service accounts whose password changed. Because the event repeats for attempts on a locked account, one such device can write several.
Microsoft notes that the Client IP of extranet lockout events can be one of Microsoft's addresses: legacy authentication through Exchange Online, where Exchange Online submits the password for the client.
Keeping it manageable
- Keep every 516: the library's lockout rule reads each one, and the volume is low.
- Group the events by Client IP and by User: one address that locks out many users is a spray, one user locked out from the user's own address is usually a device with an old password.
- When Client IP is a Microsoft address, the submitter is not in this event. On AD FS 2016 and later, take it from the XML of the 1203 or 1210 events of the same user and time, where the forwarded client address comes first.
- Have the devices that lock their users out updated rather than excluding the users: an excluded user is also excluded when the next spray reaches that account.
Attacks this event reveals
Detection rules that read this event:
Frequently asked questions
What does AD FS event 516 mean?
The user's bad password count reached the extranet lockout threshold, or AD FS received another attempt for a user who is already locked out. AD FS then refuses the user's password requests from the extranet until the observation window has passed. The domain account is not locked.
Why does event 516 show a Microsoft IP address?
Legacy authentication through Exchange Online: Exchange Online submits the user name and password to AD FS for the client, so its server is the address AD FS sees. Microsoft says the submitter's own address is in x-ms-forwarded-client-ip. Microsoft recommends moving clients to modern authentication and disabling legacy endpoints that are not needed.
Is AD FS event 516 the same as event 4740?
No. 516 is written by an AD FS server when it locks a user out for extranet sign-ins; the account in Active Directory stays usable inside the network. 4740 is written by a domain controller when the account itself is locked out in the domain.
References
- AD FS Extranet Lockout and Extranet Smart Lockout overview (Microsoft)
- Demystify extranet lockout feature in AD FS 3.0, the lockout audits (Microsoft, archived 2015 post)
- Configure AD FS Extranet Lockout Protection (Microsoft)
- Password spray investigation (Microsoft)
- Troubleshoot account lockout in AD FS on Windows Server (Microsoft)
- Required updates for AD FS and Web Application Proxy (Microsoft)