protected void LogPeriodicEvent(ExEventLog.EventTuple eventInfo, params object[] messageArguments) { string periodicKey = this.context.InvocationInfo.ShellHostName; if (this.context.UserInfo.CurrentOrganizationId != null && !OrganizationId.ForestWideOrgId.Equals(this.context.UserInfo.CurrentOrganizationId)) { periodicKey = this.context.UserInfo.CurrentOrganizationId.ToString(); } TaskLogger.LogEvent(eventInfo, this.context.InvocationInfo, periodicKey, messageArguments); }
internal static void LogRbacEvent(ExEventLog.EventTuple eventInfo, string periodicKey, params object[] messageArguments) { if (messageArguments == null) { throw new ArgumentNullException("messageArguments"); } object[] array = new object[messageArguments.Length + 2]; array[0] = TaskLogger.processName; array[1] = TaskLogger.processId; messageArguments.CopyTo(array, 2); TaskLogger.LogEvent(TaskLogger.rbacEventLogger.Value, eventInfo, periodicKey, array); }
private void CheckForExpiredSession() { IExpiringRunspaceConfiguration expiringRunspaceConfiguration = this.context.ExchangeRunspaceConfig as IExpiringRunspaceConfiguration; if (expiringRunspaceConfiguration != null && expiringRunspaceConfiguration.ShouldCloseDueToExpiration()) { TaskLogger.LogEvent(TaskEventLogConstants.Tuple_PowershellSessionExpired, this.context.InvocationInfo, this.context.ExchangeRunspaceConfig.IdentityName, new object[0]); if (this.context.CommandShell != null) { this.context.CommandShell.WriteError(new SessionExpiredException(), ExchangeErrorCategory.ServerTransient, null, false); this.context.CommandShell.SetShouldExit(-1); } } }
public static void LogEvent(ExEventLog.EventTuple eventInfo, TaskInvocationInfo invocationInfo, string periodicKey, params object[] messageArguments) { if (TaskLogger.IsSetupLogging) { return; } if (messageArguments == null) { throw new ArgumentNullException("messageArguments"); } object[] array = new object[messageArguments.Length + 3]; array[0] = TaskLogger.processId; array[1] = Environment.CurrentManagedThreadId; array[2] = invocationInfo.DisplayName; messageArguments.CopyTo(array, 3); TaskLogger.LogEvent(invocationInfo.ShellHostName, eventInfo, periodicKey, array); }
private void InitializePiiRedaction() { string text = Path.Combine(ExchangeSetupContext.InstallPath, "ClientAccess\\PowerShell-Proxy\\CmdletDataRedaction.xml"); Exception ex = null; string text2; try { text2 = SuppressingPiiProperty.Initialize(text); } catch (IOException ex2) { ex = ex2; text2 = string.Format("IOException occurred while loading the configuration file. Please make sure the CmdletDataRedaction.xml is accessible. Expected path: {0}, Details: {1}", text, ex2); } catch (InvalidOperationException ex3) { ex = ex3; text2 = string.Format("An error occurred during deserializing file {0}, please make sure the XML file is well-formatted and complies with the XML schema definition. Details: {1}", text, ex3); } if (text2 != null) { if (ex != null) { this.CurrentTaskContext.CommandShell.WriteError(new LocalizedException(LocalizedString.Empty, ex), ExchangeErrorCategory.ServerOperation, text); } else { this.CurrentTaskContext.CommandShell.WriteWarning(Strings.PiiRedactionInitializationFailed(text2)); } TaskLogger.LogEvent("All", TaskEventLogConstants.Tuple_FailedToInitailizeCmdletDataRedactionConfiguration, new object[] { text2 }); } }
public static void LogEvent(string hostName, ExEventLog.EventTuple eventInfo, string periodicKey, params object[] messageArguments) { TaskLogger.LogEvent(TaskLogger.GetEventLogger(hostName), eventInfo, periodicKey, messageArguments); }
public static void LogEvent(string hostName, ExEventLog.EventTuple eventInfo, params object[] messageArguments) { TaskLogger.LogEvent(hostName, eventInfo, null, messageArguments); }
// Token: 0x060015C1 RID: 5569 RVA: 0x00050C28 File Offset: 0x0004EE28 private void LogCmdletIterationEvent() { bool flag = this.context.ExchangeRunspaceConfig == null; bool flag2 = VariantConfiguration.InvariantNoFlightingSnapshot.CmdletInfra.WriteEventLogInEnglish.Enabled && (CultureInfo.CurrentUICulture != CmdletLogHelper.DefaultLoggingCulture || CultureInfo.CurrentCulture != CmdletLogHelper.DefaultLoggingCulture); object[] array = new object[27]; array[0] = ((this.context.InvocationInfo != null) ? this.context.InvocationInfo.DisplayName : string.Empty); array[1] = ((this.context.InvocationInfo == null) ? null : TaskVerboseStringHelper.FormatUserSpecifiedParameters(this.context.InvocationInfo.UserSpecifiedParameters ?? new PropertyBag())); array[2] = (flag ? ((this.context.UserInfo != null && this.context.UserInfo.ExecutingUserId != null) ? this.context.UserInfo.ExecutingUserId.ToString() : string.Empty) : this.context.ExchangeRunspaceConfig.IdentityName); array[3] = (flag ? null : this.context.ExchangeRunspaceConfig.LogonUserSid); array[4] = null; if (!flag) { SecurityIdentifier securityIdentifier = null; this.context.ExchangeRunspaceConfig.TryGetExecutingUserSid(out securityIdentifier); array[4] = securityIdentifier; } array[5] = this.GenerateApplicationString(); array[6] = CmdletIterationEventModule.processIdAndName; array[7] = (flag ? ((this.context.UserInfo != null) ? this.context.UserInfo.CurrentOrganizationId : null) : this.context.ExchangeRunspaceConfig.OrganizationId); array[8] = Environment.CurrentManagedThreadId; DateTime utcNow = DateTime.UtcNow; array[9] = utcNow.Subtract(this.lastDateTimeValue); this.lastDateTimeValue = utcNow; ADDriverContext threadADContext = ADSessionSettings.GetThreadADContext(); if (threadADContext == null) { array[10] = null; } else { array[10] = (flag2 ? TaskVerboseStringHelper.GetADServerSettings(null, threadADContext.ServerSettings, CmdletLogHelper.DefaultLoggingCulture) : TaskVerboseStringHelper.GetADServerSettings(null, threadADContext.ServerSettings, null)); } if (this.context.ErrorInfo.HasErrors) { if (this.context.ErrorInfo.Exception != null) { Exception exception = this.context.ErrorInfo.Exception; array[11] = exception; array[12] = this.context.ErrorInfo.ExchangeErrorCategory.Value; if (exception != null && exception.InnerException != null) { array[13] = exception.InnerException; } if (exception is LocalizedException) { array[14] = ((LocalizedException)exception).LocalizedString.StringId; if (!flag2) { goto IL_2DE; } LocalizedException ex = (LocalizedException)exception; IFormatProvider formatProvider = ex.FormatProvider; try { ex.FormatProvider = CmdletLogHelper.DefaultLoggingCulture; array[11] = ex.ToString(); goto IL_2DE; } finally { ex.FormatProvider = formatProvider; } } array[14] = "NonLocalizedException"; } else { array[11] = "null"; } } IL_2DE: object obj; this.context.Items.TryGetValue("Log_AdditionalLogData", out obj); array[15] = obj; LocalizedString delayedInfo = ThrottlingModule <ResourceThrottlingCallback> .GetDelayedInfo(this.context); if (!string.IsNullOrEmpty(delayedInfo)) { array[16] = (flag2 ? delayedInfo.ToString(CmdletLogHelper.DefaultLoggingCulture) : delayedInfo) + ThrottlingModule <ResourceThrottlingCallback> .GetThrottlingInfo(this.context); } array[17] = SuppressingPiiContext.NeedPiiSuppression; this.context.Items.TryGetValue("Log_CmdletProxyInfo", out obj); array[18] = obj; if (this.context.Items.TryGetValue("Log_ProxiedObjectCount", out obj)) { obj = string.Format("{0} objects execution has been proxied to remote server.", obj); } array[19] = obj; if (this.context.Items.TryGetValue("Log_RequestQueryFilterInGetTasks", out obj)) { array[20] = string.Format("Request Filter used is: {0}", obj); } if (this.context.Items.TryGetValue("Log_InternalQueryFilterInGetTasks", out obj)) { array[21] = string.Format("Cmdlet Filter used is: {0}", obj); } array[22] = this.outputObjectCount; array[23] = "ActivityId: " + ((ActivityContext.ActivityId != null) ? ActivityContext.ActivityId.Value.ToString() : string.Empty); if (!flag && this.context.ExchangeRunspaceConfig != null) { array[24] = this.context.ExchangeRunspaceConfig.GetRBACInformationSummary(); } if (Constants.IsPowerShellWebService && HttpContext.Current != null && HttpContext.Current.Request != null && HttpContext.Current.Request.Headers != null) { array[25] = HttpContext.Current.Request.Headers["client-request-id"]; } array[26] = CultureInfo.CurrentUICulture.Name; ExEventLog.EventTuple eventInfo; if (this.context.ErrorInfo.HasErrors) { eventInfo = TaskEventLogConstants.Tuple_LogCmdletError; } else if (this.context.WasCancelled) { eventInfo = TaskEventLogConstants.Tuple_LogCmdletCancelled; } else if (this.wasStopped) { eventInfo = TaskEventLogConstants.Tuple_LogCmdletStopped; } else { eventInfo = this.CmdletSuccessEventTuple; } try { TaskLogger.LogEvent("All", eventInfo, array); } catch (ArgumentException ex2) { if (this.context.CommandShell != null) { this.context.CommandShell.WriteWarning(Strings.WarningCannotWriteToEventLog(ex2.ToString())); } } }