Author: Andrew Rathbun
Description: A directory service object was undeleted
EventId: 5138
Channel: Security
Provider: Microsoft-Windows-Security-Auditing
Maps:
  -
    Property: UserName
    PropertyValue: "%domain%\\%user%"
    Values:
      -
        Name: domain
        Value: "/Event/EventData/Data[@Name=\"SubjectDomainName\"]"
      -
        Name: user
        Value: "/Event/EventData/Data[@Name=\"SubjectUserName\"]"
  -
    Property: PayloadData1
    PropertyValue: "DSName: %DSName%"
    Values:
      -
        Name: DSName
        Value: "/Event/EventData/Data[@Name=\"DSName\"]"
  -
    Property: PayloadData2
    PropertyValue: "OldObjectDN: %OldObjectDN%"
    Values:
      -
        Name: OldObjectDN
        Value: "/Event/EventData/Data[@Name=\"OldObjectDN\"]"
  -
    Property: PayloadData3
    PropertyValue: "NewObjectDN: %NewObjectDN%"
    Values:
      -
        Name: NewObjectDN
        Value: "/Event/EventData/Data[@Name=\"NewObjectDN\"]"

# Documentation:
# https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/event.aspx?eventid=5138
# https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-5138
# https://github.com/nasbench/EVTX-ETW-Resources/blob/main/ETWProvidersCSVs/Internal/Microsoft-Windows-Security-Auditing.csv
#
# Example Event Data:
#  <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
#  <System>
# <Provider Name="Microsoft-Windows-Security-Auditing" Guid="{54849625-5478-4994-A5BA-3E3B0328C30D}" />
# <EventID>5138</EventID>
# <Version>0</Version>
# <Level>0</Level>
# <Task>14081</Task>
# <Opcode>0</Opcode>
# <Keywords>0x8020000000000000</Keywords>
# <TimeCreated SystemTime="2015-09-02T04:34:20.611082300Z" />
# <EventRecordID>229336</EventRecordID>
# <Correlation />
# <Execution ProcessID="516" ThreadID="544" />
# <Channel>Security</Channel>
# <Computer>DC01.contoso.local</Computer>
# <Security />
# </System>
#  <EventData>
# <Data Name="OpCorrelationID">{3E2B5ECF-4C35-4C3F-8D82-B8D6F477D846}</Data>
# <Data Name="AppCorrelationID">-</Data>
# <Data Name="SubjectUserSid">S-1-5-21-3457937927-2839227994-823803824-1104</Data>
# <Data Name="SubjectUserName">dadmin</Data>
# <Data Name="SubjectDomainName">CONTOSO</Data>
# <Data Name="SubjectLogonId">0x3be49</Data>
# <Data Name="DSName">contoso.local</Data>
# <Data Name="DSType">%%14676</Data>
# <Data Name="OldObjectDN">CN=Andrei\\0ADEL:53511188-bc98-4995-9d78-2d40143c9711,CN=Deleted Objects,DC=contoso,DC=local</Data>
# <Data Name="NewObjectDN">CN=Andrei,CN=Users,DC=contoso,DC=local</Data>
# <Data Name="ObjectGUID">{53511188-BC98-4995-9D78-2D40143C9711}</Data>
# <Data Name="ObjectClass">user</Data>
# </EventData>
#  </Event>
