Exemplo n.º 1
0
        /// <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;
            }
        }
Exemplo n.º 2
0
        /// <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);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        /// <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);
        }