public static void PerformAuditSuccessActions(LapRequestModel model, TargetElement target, ReaderElement reader, UserPrincipal user, ComputerPrincipal computer, SearchResult searchResult) { Dictionary <string, string> tokens = BuildTokenDictionary(target, reader, user, computer, searchResult, model.ComputerName); string logSuccessMessage = Reporting.LogSuccessTemplate ?? LogMessages.DefaultAuditSuccessText; string emailSuccessMessage = Reporting.EmailSuccessTemplate ?? $"<html><head/><body><pre>{LogMessages.DefaultAuditSuccessText}</pre></body></html>"; LogEventInfo logEvent = new LogEventInfo(LogLevel.Info, Reporting.Logger.Name, ReplaceTokens(tokens, logSuccessMessage, false)); logEvent.Properties.Add("EventID", EventIDs.PasswordAccessed); Reporting.Logger.Log(logEvent); try { ICollection <string> recipients = Reporting.BuildRecipientList(target, reader, true, user); if (recipients.Count > 0) { string subject = ReplaceTokens(tokens, LogMessages.AuditEmailSubjectSuccess, false); Reporting.SendEmail(recipients, subject, ReplaceTokens(tokens, emailSuccessMessage, true)); } } catch (Exception iex) { Reporting.LogErrorEvent(EventIDs.AuditErrorCannotSendSuccessEmail, "An error occurred sending the success audit email", iex); } }
public static void PerformAuditFailureActions(LapRequestModel model, string userMessage, int eventID, string logMessage, Exception ex, TargetElement target, ReaderElement reader, UserPrincipal user, ComputerPrincipal computer) { Dictionary <string, string> tokens = BuildTokenDictionary(target, reader, user, computer, null, model.ComputerName, logMessage ?? userMessage); string logFailureMessage = Reporting.LogFailureTemplate ?? LogMessages.DefaultAuditFailureText; string emailFailureMessage = Reporting.EmailFailureTemplate ?? $"<html><head/><body><pre>{LogMessages.DefaultAuditFailureText}</pre></body></html>"; Reporting.LogErrorEvent(eventID, ReplaceTokens(tokens, logFailureMessage, false), ex); try { ICollection <string> recipients = Reporting.BuildRecipientList(target, reader, false); if (recipients.Count > 0) { string subject = ReplaceTokens(tokens, LogMessages.AuditEmailSubjectFailure, false); Reporting.SendEmail(recipients, subject, ReplaceTokens(tokens, emailFailureMessage, true)); } } catch (Exception iex) { Reporting.LogErrorEvent(EventIDs.AuditErrorCannotSendFailureEmail, "An error occurred sending the failure audit email", iex); } }