Im trying to determine a machines most frequent user by looking at the security event logs. im looking at using the 4624 Event ID but I cant seem to work out how to add anything from the EventData in the query. I can get the standard data from a 4624 event but what im trying to query is events that also have the logontype of 7 and then be able to read the targetusername details.
thanks!
string query = @"*[System/EventID=4624]";
EventLogQuery eventsQuery = new EventLogQuery("Security", PathType.LogName, query);
try
{
EventLogReader logReader = new EventLogReader(eventsQuery);
for (EventRecord eventdetail = logReader.ReadEvent(); eventdetail != null; eventdetail = logReader.ReadEvent())
{
Console.WriteLine(eventdetail.ProcessId);
}
}
catch (EventLogNotFoundException)
{
Console.WriteLine("Error while reading the event logs");
return;
}