// Token: 0x06001675 RID: 5749 RVA: 0x00055040 File Offset: 0x00053240 private void PersistNewServerSettings(ADServerSettings newServerSettings) { if (newServerSettings != null) { ADSessionSettings.ClearThreadADContext(); LocalizedString adserverSettings; if (CmdletLogHelper.NeedConvertLogMessageToUS) { adserverSettings = TaskVerboseStringHelper.GetADServerSettings(this.context.InvocationInfo.CommandName, newServerSettings, CmdletLogHelper.DefaultLoggingCulture); } else { adserverSettings = TaskVerboseStringHelper.GetADServerSettings(this.context.InvocationInfo.CommandName, newServerSettings); } if (this.context.SessionState != null) { CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "ADServerSettings-FailOver", adserverSettings); ExchangePropertyContainer.SetServerSettings(this.context.SessionState, newServerSettings); } else { CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "ADServerSettings-NOTFailOver-SessionStateNull", adserverSettings); } ADSessionSettings.SetThreadADContext(new ADDriverContext(newServerSettings, ContextMode.Cmdlet)); this.context.ServerSettingsAfterFailOver = newServerSettings; this.context.CommandShell.WriteWarning(DirectoryStrings.RunspaceServerSettingsChanged); return; } CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "ADServerSettings-NOTFailOver-ServerSettingsNull", "NULL"); }
public static LocalizedString GetADServerSettings(string cmdletName, ADServerSettings serverSettings) { return(TaskVerboseStringHelper.GetADServerSettings(cmdletName, serverSettings, null)); }
public static LocalizedString GetADServerSettings(ADServerSettings serverSettings) { return(TaskVerboseStringHelper.GetADServerSettings(null, serverSettings)); }
// 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())); } } }
private void InitializeRunspaceServerSettings(object sender, EventArgs e) { ISessionState sessionState = this.CurrentTaskContext.SessionState; ADServerSettings adserverSettings = null; bool flag = false; bool flag2 = false; string value = null; if (sessionState != null) { flag2 = ExchangePropertyContainer.IsContainerInitialized(sessionState); if (flag2) { adserverSettings = ExchangePropertyContainer.GetServerSettings(sessionState); if (adserverSettings != null) { value = "SessionState"; } } } if (adserverSettings == null) { adserverSettings = ADSessionSettings.GetProcessServerSettings(); if (adserverSettings != null) { value = "ProcessServerSettings"; } } if (adserverSettings == null) { if (this.CurrentTaskContext.CommandShell != null) { this.CurrentTaskContext.CommandShell.TryGetVariableValue <ADServerSettings>(ExchangePropertyContainer.ADServerSettingsVarName, out adserverSettings); } flag = (adserverSettings != null); if (adserverSettings != null) { value = "CommandShell"; } } if (TopologyProvider.CurrentTopologyMode == TopologyMode.ADTopologyService) { ADServerSettings cmdletADServerSettings = this.GetCmdletADServerSettings(); if (cmdletADServerSettings != null) { this.CurrentTaskContext.Items["CmdletServerSettings"] = cmdletADServerSettings; value = "ADTopologyService"; adserverSettings = cmdletADServerSettings; } } if (adserverSettings == null) { flag = true; if (TopologyProvider.CurrentTopologyMode == TopologyMode.Adam) { if (this.CurrentTaskContext.InvocationInfo != null && this.CurrentTaskContext.InvocationInfo.IsVerboseOn) { this.CurrentTaskContext.CommandShell.WriteVerbose(Strings.VerboseInitializeRunspaceServerSettingsAdam); } if (Globals.InstanceType == InstanceType.NotInitialized) { Globals.InitializeSinglePerfCounterInstance(); } value = "Adam-SimpleServerSettings"; adserverSettings = new SimpleServerSettings(); } else if (TopologyProvider.CurrentTopologyMode == TopologyMode.Ldap) { if (this.CurrentTaskContext.InvocationInfo != null && this.CurrentTaskContext.CommandShell != null && this.CurrentTaskContext.InvocationInfo.IsVerboseOn) { this.CurrentTaskContext.CommandShell.WriteVerbose(Strings.VerboseInitializeRunspaceServerSettingsLocal); } Globals.InitializeMultiPerfCounterInstance("EMS"); value = "Ldap-LocalCmdLineServerSettings"; adserverSettings = LocalCmdLineServerSettings.CreateLocalCmdLineServerSettings(); } else { if (this.CurrentTaskContext.InvocationInfo != null && this.CurrentTaskContext.InvocationInfo.IsVerboseOn) { this.CurrentTaskContext.CommandShell.WriteVerbose(Strings.VerboseInitializeRunspaceServerSettingsRemote); } adserverSettings = this.CreateADServerSettingsForOrganization(false); if (adserverSettings == null) { value = "GCRandomly"; adserverSettings = RunspaceServerSettings.CreateRunspaceServerSettings(false); } } } if (flag) { if (flag2) { ExchangePropertyContainer.SetServerSettings(sessionState, adserverSettings); } else { sessionState.Variables[ExchangePropertyContainer.ADServerSettingsVarName] = adserverSettings; } } ADSessionSettings.SetThreadADContext(new ADDriverContext(adserverSettings, ContextMode.Cmdlet)); LocalizedString localizedString = LocalizedString.Empty; if (this.CurrentTaskContext.InvocationInfo != null) { localizedString = TaskVerboseStringHelper.GetADServerSettings(this.CurrentTaskContext.InvocationInfo.CommandName, adserverSettings); if (this.CurrentTaskContext.InvocationInfo.IsVerboseOn && !string.Equals(this.CurrentTaskContext.InvocationInfo.CommandName, "Write-ExchangeSetupLog", StringComparison.OrdinalIgnoreCase) && this.CurrentTaskContext.CommandShell != null) { this.CurrentTaskContext.CommandShell.WriteVerbose(localizedString); } } CmdletLogger.SafeSetLogger(this.CurrentTaskContext.UniqueId, RpsCmdletMetadata.RunspaceSettingsCreationHint, value); CmdletLogHelper.LogADServerSettings(this.CurrentTaskContext.UniqueId, adserverSettings); if (ExTraceGlobals.LogTracer.IsTraceEnabled(TraceType.InfoTrace)) { ExTraceGlobals.LogTracer.Information <LocalizedString>(0L, "Cmdlet ADServerSettings {0}", localizedString); } }