/// <summary> /// List all records matching the filter options. /// </summary> void List() { LogonEventAdapter adapter = new LogonEventAdapter(this.options.Credentials); List <LogonEvent> events = adapter.Find(options.Filter, options.Match); ProgramOutput output = new ProgramOutput(); switch (options.GetFormat()) { case Options.Format.Compact: output.SetFormat(new OutputFormatCompact()); output.Write(events); break; case Options.Format.Human: output.SetFormat(new OutputFormatHuman()); output.Write(events); break; case Options.Format.Tabbed: output.SetFormat(new OutputFormatTabbed()); output.Write(events); break; case Options.Format.XML: output.SetFormat(new OutputFormatXML()); output.Write(events); break; } }
/// <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); }
protected void OnSessionLogon(int sessionId) { Account account = new Account(GetSessionUser(sessionId)); EventLog.WriteEntry( string.Format("User {0}\\{1} logged on", account.Domain, account.UserName), EventLogEntryType.Information, 528 ); LogonEventProxy proxy = new LogonEventProxy(account); LogonEventAdapter adapter = new LogonEventAdapter(credentials); proxy.Add(adapter); }
/// <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); }
/// <summary> /// Records an login event. /// </summary> void Login() { Account account = new Account(); try { EventLog.WriteEntry( ProgramInfo.Product, string.Format("User {0}\\{1} logged on", account.Domain, account.UserName), EventLogEntryType.Information, 528 ); } catch (System.Security.SecurityException exception) { Report(exception); } LogonEventProxy proxy = new LogonEventProxy(account); LogonEventAdapter adapter = new LogonEventAdapter(this.options.Credentials); proxy.Add(adapter); }