A deleted AD object was restored from the AD Recycle Bin.
Restoration of deleted backdoor accounts previously cleaned up. May be used to restore access without re-creating accounts.
Alert: restoration of accounts or objects outside documented recovery procedures.
SubjectUserNameTargetUserNameLogonTypeIpAddressWorkstationName Starting points — adapt the log source, projected fields and thresholds for your environment.
SecurityEvent
| where EventID == 5138 // A directory service object was undeleted
| project TimeGenerated, Computer, SubjectUserName, TargetUserName, LogonType, IpAddress, WorkstationName
| sort by TimeGenerated desc
index=* sourcetype="WinEventLog:Security" EventCode=5138
| stats count earliest(_time) as first_seen latest(_time) as last_seen by ComputerName
| sort - count `# A directory service object was undeleted — add EventData fields: SubjectUserName, TargetUserName, LogonType, IpAddress`
A directory service object was undeleted. A deleted AD object was restored from the AD Recycle Bin.
Event 5138 is written to the Security channel by Microsoft-Windows-Security-Auditing. Advanced Audit Policy — enable the 'DS Access' subcategory (Success and/or Failure).
Alert: restoration of accounts or objects outside documented recovery procedures.