-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDSCreated.cs
More file actions
52 lines (46 loc) · 1.5 KB
/
DSCreated.cs
File metadata and controls
52 lines (46 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.DirectoryServices;
using System.Linq;
using System.Runtime.Caching;
using System.Text;
using System.Threading.Tasks;
namespace PropertyChange
{
class DSCreated : DSEvent<DSCreatedRecord>
{
public DSCreated(string remoteComputer, string domain, string username, string password)
: base(remoteComputer, domain, username, password) { }
public DSCreated(string remoteComputer)
: base(remoteComputer) { }
public DSCreated() : base() { }
protected override string GetQueryString()
{
return "*[System[EventID=5137]]";
}
protected override DSCreatedRecord Parse(EventRecord item)
{
var ds = new DSCreatedRecord();
ds.Time = item.TimeCreated.Value;
ds.Target = item.Properties[8].Value as string;
ds.Operator = item.Properties[3].Value as string;
try
{
ds.TargetGuid = new Guid(((string)item.Properties[9].Value).Trim(' ', '%', '{', '}'));
}
catch
{
ds.TargetGuid = Guid.Empty;
}
return ds;
}
}
class DSCreatedRecord
{
public Guid TargetGuid { get; set; }
public DateTime Time { get; set; }
public String Target { get; set; } // ObjectDN
public String Operator { get; set; } // SubjectUserName
}
}