/// <summary> /// Close all records matching the filter options. /// </summary> void Close() { LogonEventAdapter adapter = new LogonEventAdapter(this.options.Credentials); List <LogonEvent> events = adapter.Find(options.Filter, options.Match); foreach (LogonEvent record in events) { adapter.Close(record); } }
protected void OnSessionLogoff(int sessionId) { Account account = new Account(GetSessionUser(sessionId)); EventLog.WriteEntry( string.Format("User {0}\\{1} logged off", account.Domain, account.UserName), EventLogEntryType.Information, 528 ); LogonEventAdapter adapter = new LogonEventAdapter(credentials); LogonEvent record = adapter.Find(account); adapter.Close(record.EventID); }
/// <summary> /// Records an logout event. The event ID is remotelly queried using the logged on /// user and domain as search preferences. The current workstation is detected /// automatic. /// </summary> void Logout() { Account account = new Account(); try { EventLog.WriteEntry( ProgramInfo.Product, string.Format("User {0}\\{1} logged off", account.Domain, account.UserName), EventLogEntryType.Information, 528 ); } catch (System.Security.SecurityException exception) { Report(exception); } LogonEventAdapter adapter = new LogonEventAdapter(this.options.Credentials); LogonEvent record = adapter.Find(account); adapter.Close(record.EventID); }