CyberKit

Event IDs

Security event 5138

A directory service object was undeleted

Channel: Security. Category: DS Access (Audit Directory Service Changes).

What it records

Generated on an Active Directory domain controller whenever an AD object is undeleted, for example, restored from the Active Directory Recycle Bin. It only fires if the destination container has a matching 'Create' auditing entry in its SACL for that object class. Records the requesting Subject, the AD domain, the object's Old DN (its tombstone path under CN=Deleted Objects), New DN (the container it was restored into), GUID, and object Class.

Why it matters

Undelete operations are rare in routine AD administration, so Microsoft's own guidance is to monitor every occurrence and confirm a legitimate reason exists. An unexpected 5138 can indicate anti-forensic activity: an intruder restoring a previously deleted, still-privileged account or object for renewed access, or putting a deleted object back to make earlier tampering less conspicuous.

What triggers it

Legitimately: an administrator restoring an accidentally deleted user, group, or computer object via Active Directory Administrative Center or the Restore-ADObject PowerShell cmdlet. Rarely and suspiciously: an attacker restoring a dormant privileged object as part of a persistence or anti-forensic play. The event only generates at all when the destination container's SACL audits 'Create' for that object class.

Fields that carry the answer

Key fields
FieldWhat it tells you
Subject > Account NameWho performed the restore. Verify it's a legitimate admin action tied to a known recovery request.
Object > New DNThe container the object was restored into. Flag restores into privileged OUs or containers with no matching change ticket.
Object > Old DNThe object's pre-restore path under CN=Deleted Objects, which confirms this was a genuine tombstone recovery rather than some other object-creation path.
Object > ClassThe class of the restored object (user, group, groupPolicyContainer, etc.): a restored privileged account or GPO warrants closer review than a routine user restore.

In practice

An administrator restores the AD user object 'jdoe' via Active Directory Administrative Center after an accidental deletion; Object > Old DN shows CN=jdoe\0ADEL:8f14e45f-ceea-167a-5a36-dedd4bea2543,CN=Deleted Objects,DC=corp,DC=example,DC=com and New DN shows CN=jdoe,CN=Users,DC=corp,DC=example,DC=com. Routine recovery, but the same event restoring a dormant admin account with no matching help-desk ticket deserves scrutiny.

Sample record

A directory service object was undeleted.

Subject:
	Security ID:		S-1-5-21-3623811015-3361044348-30300820-500
	Account Name:		administrator
	Account Domain:		CORP
	Logon ID:		0x3E7F2A1

Directory Service:
	Name:		corp.example.com
	Type:		Active Directory Domain Services

Object:
	Old DN:		CN=jdoe\0ADEL:8f14e45f-ceea-167a-5a36-dedd4bea2543,CN=Deleted Objects,DC=corp,DC=example,DC=com
	New DN:		CN=jdoe,CN=Users,DC=corp,DC=example,DC=com
	GUID:		{8F14E45F-CEEA-167A-5A36-DEDD4BEA2543}
	Class:		user

Operation:
	Correlation ID:		{3E2B5ECF-4C35-4C3F-8D82-B8D6F477D846}
	Application Correlation ID:	-

Sources

Paste a record into Event XML or open a log in EVTX Reader.