protected override void InitializeRunspace(Runspace runspace)
            {
                base.InitializeRunspace(runspace);
                RunspaceServerSettings value = RunspaceServerSettings.CreateGcOnlyRunspaceServerSettings(this.affinityToken, false);

                runspace.SessionStateProxy.SetVariable(ExchangePropertyContainer.ADServerSettingsVarName, value);
            }
示例#2
0
 // Token: 0x06005B06 RID: 23302 RVA: 0x0013F05C File Offset: 0x0013D25C
 internal RunspaceServerSettingsPresentationObject(RunspaceServerSettings serverSettings) : base(new SimpleProviderPropertyBag())
 {
     if (serverSettings == null)
     {
         throw new ArgumentNullException("The value of parameter serverSettings is null!");
     }
     this.UserPreferredGlobalCatalog                         = serverSettings.UserPreferredGlobalCatalog;
     this.DefaultGlobalCatalog                               = serverSettings.GetSingleDefaultGlobalCatalog();
     this.DefaultGlobalCatalogsForAllForests                 = RunspaceServerSettingsPresentationObject.ConvertStringDictionaryToMVP <string, Fqdn>(serverSettings.PreferredGlobalCatalogs);
     this.UserPreferredConfigurationDomainController         = serverSettings.UserConfigurationDomainController;
     this.DefaultConfigurationDomainController               = serverSettings.GetSingleDefaultConfigurationDomainController();
     this.DefaultConfigurationDomainControllersForAllForests = RunspaceServerSettingsPresentationObject.ConvertStringDictionaryToMVP <string, Fqdn>(serverSettings.ConfigurationDomainControllers);
     this.userServerPerDomain               = RunspaceServerSettingsPresentationObject.ConvertStringDictionaryToMVP <ADObjectId, Fqdn>(serverSettings.UserServerPerDomain);
     this.UserPreferredDomainControllers    = new MultiValuedProperty <Fqdn>(serverSettings.UserPreferredDomainControllers);
     this.DefaultPreferredDomainControllers = new MultiValuedProperty <Fqdn>(serverSettings.PreferredDomainControllers);
     if (serverSettings.RecipientViewRoot == null)
     {
         this.RecipientViewRoot = string.Empty;
     }
     else
     {
         this.RecipientViewRoot = serverSettings.RecipientViewRoot.ToCanonicalName();
     }
     this.ViewEntireForest = serverSettings.ViewEntireForest;
     this.WriteOriginatingChangeTimestamp = serverSettings.WriteOriginatingChangeTimestamp;
     this.WriteShadowProperties           = serverSettings.WriteShadowProperties;
     this.rawServerSettings = serverSettings;
 }
示例#3
0
 protected override string GetRunspaceServerSettingsToken()
 {
     if (Datacenter.IsMultiTenancyEnabled() && RbacPrincipal.Current.IsAdmin && !OrganizationId.ForestWideOrgId.Equals(RbacPrincipal.Current.RbacConfiguration.OrganizationId))
     {
         return(RunspaceServerSettings.GetTokenForOrganization(RbacPrincipal.Current.RbacConfiguration.OrganizationId));
     }
     return(base.GetRunspaceServerSettingsToken());
 }
示例#4
0
 private ADServerSettings CreateServerSettingsForUserWithForestWideAffinity(string userIdentity, OrganizationId orgId)
 {
     if (string.IsNullOrEmpty(userIdentity) || orgId == null || ADSessionSettings.IsForefrontObject(orgId.PartitionId) || orgId.Equals(OrganizationId.ForestWideOrgId))
     {
         return(null);
     }
     return(RunspaceServerSettings.CreateGcOnlyRunspaceServerSettings(RunspaceServerSettings.GetTokenForUser(userIdentity, orgId), orgId.PartitionId.ForestFQDN, true));
 }
示例#5
0
 private ADServerSettings CreateServerSettings(OrganizationId orgId, bool useDCInAnySite)
 {
     if (orgId == null || ADSessionSettings.IsForefrontObject(orgId.PartitionId) || orgId.Equals(OrganizationId.ForestWideOrgId))
     {
         return(null);
     }
     return(RunspaceServerSettings.CreateGcOnlyRunspaceServerSettings(RunspaceServerSettings.GetTokenForOrganization(orgId), orgId.PartitionId.ForestFQDN, useDCInAnySite));
 }
示例#6
0
        internal static void LogADServerSettingsAfterCmdExecuted(Guid cmdletUniqueId, ADServerSettings serverSettings)
        {
            string        key           = "ADServerSettingsInEnd";
            StringBuilder stringBuilder = new StringBuilder();
            string        format        = "{0}:{1} ";

            if (serverSettings == null)
            {
                CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, key, "null");
                return;
            }
            stringBuilder.AppendFormat(format, RpsCmdletMetadata.ADViewEntireForest.ToString(), serverSettings.ViewEntireForest);
            if (serverSettings.RecipientViewRoot != null)
            {
                stringBuilder.AppendFormat(format, RpsCmdletMetadata.ADRecipientViewRoot.ToString(), serverSettings.RecipientViewRoot.ToCanonicalName());
            }
            if (serverSettings.ConfigurationDomainControllers != null)
            {
                stringBuilder.AppendFormat(format, RpsCmdletMetadata.ADConfigurationDomainControllers, string.Join <Fqdn>(",", serverSettings.ConfigurationDomainControllers.Values));
            }
            if (serverSettings.PreferredGlobalCatalogs != null)
            {
                stringBuilder.AppendFormat(format, RpsCmdletMetadata.ADPreferredGlobalCatalogs.ToString(), string.Join <Fqdn>(",", serverSettings.PreferredGlobalCatalogs.Values));
            }
            if (serverSettings.PreferredDomainControllers != null)
            {
                stringBuilder.AppendFormat(format, RpsCmdletMetadata.ADPreferredDomainControllers.ToString(), string.Join <Fqdn>(",", serverSettings.PreferredDomainControllers.ToArray()));
            }
            RunspaceServerSettings runspaceServerSettings = serverSettings as RunspaceServerSettings;

            if (runspaceServerSettings == null)
            {
                CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, key, stringBuilder.ToString());
                CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "RunspaceServerSettings", "null");
                return;
            }
            if (runspaceServerSettings.UserConfigurationDomainController != null)
            {
                stringBuilder.AppendFormat(format, RpsCmdletMetadata.ADUserConfigurationDomainController.ToString(), runspaceServerSettings.UserConfigurationDomainController);
            }
            if (runspaceServerSettings.UserPreferredGlobalCatalog != null)
            {
                stringBuilder.AppendFormat(format, RpsCmdletMetadata.ADUserPreferredGlobalCatalog.ToString(), runspaceServerSettings.UserConfigurationDomainController);
            }
            if (runspaceServerSettings.UserPreferredDomainControllers != null)
            {
                stringBuilder.AppendFormat(format, RpsCmdletMetadata.ADUserPreferredDomainControllers.ToString(), string.Join <Fqdn>(",", runspaceServerSettings.UserPreferredDomainControllers.ToArray()));
            }
            CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, key, stringBuilder.ToString());
        }
示例#7
0
        internal override RunspaceServerSettings CreateRunspaceServerSettings()
        {
            string runspaceServerSettingsToken = this.GetRunspaceServerSettingsToken();

            if (runspaceServerSettingsToken == null)
            {
                return(RunspaceServerSettings.CreateRunspaceServerSettings(false));
            }
            OrganizationId organizationId = RbacPrincipal.Current.RbacConfiguration.OrganizationId;

            if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Eac.OrgIdADSeverSettings.Enabled&& organizationId != null && RbacPrincipal.Current.IsAdmin && !OrganizationId.ForestWideOrgId.Equals(organizationId) && !ADSessionSettings.IsForefrontObject(organizationId.PartitionId))
            {
                return(RunspaceServerSettings.CreateGcOnlyRunspaceServerSettings(runspaceServerSettingsToken.ToLowerInvariant(), organizationId.PartitionId.ForestFQDN, false));
            }
            return(RunspaceServerSettings.CreateGcOnlyRunspaceServerSettings(runspaceServerSettingsToken.ToLowerInvariant(), false));
        }
            // Token: 0x06000E81 RID: 3713 RVA: 0x00057330 File Offset: 0x00055530
            protected override void InitializeRunspace(Runspace runspace)
            {
                base.InitializeRunspace(runspace);
                string token = (this.organizationId == OrganizationId.ForestWideOrgId) ? "RootOrg" : RunspaceServerSettings.GetTokenForOrganization(this.organizationId);
                RunspaceServerSettings runspaceServerSettings;

                if (this.organizationId != null && !this.organizationId.PartitionId.IsLocalForestPartition())
                {
                    runspaceServerSettings = RunspaceServerSettings.CreateGcOnlyRunspaceServerSettings(token, this.organizationId.PartitionId.ForestFQDN, false);
                    runspaceServerSettings.RecipientViewRoot = ADSystemConfigurationSession.GetRootOrgContainerId(null, null).DomainId;
                }
                else
                {
                    runspaceServerSettings = RunspaceServerSettings.CreateGcOnlyRunspaceServerSettings(token, false);
                }
                runspace.SessionStateProxy.SetVariable(ExchangePropertyContainer.ADServerSettingsVarName, runspaceServerSettings);
            }
 protected override void InitializeRunspace(Runspace runspace)
 {
     base.InitializeRunspace(runspace);
     try
     {
         RunspaceServerSettings runspaceServerSettings = RunspaceServerSettings.CreateRunspaceServerSettings(false);
         runspaceServerSettings.ViewEntireForest = true;
         runspace.SessionStateProxy.SetVariable(ExchangePropertyContainer.ADServerSettingsVarName, runspaceServerSettings);
     }
     catch (ADTransientException)
     {
         throw;
     }
     catch (ADExternalException)
     {
         throw;
     }
 }
示例#10
0
        internal static void LogADServerSettings(Guid cmdletUniqueId, ADServerSettings serverSettings)
        {
            if (serverSettings == null)
            {
                CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "ADServerSettings", "null");
                return;
            }
            CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADViewEntireForest, serverSettings.ViewEntireForest);
            if (serverSettings.RecipientViewRoot != null)
            {
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADRecipientViewRoot, serverSettings.RecipientViewRoot.ToCanonicalName());
            }
            if (serverSettings.ConfigurationDomainControllers != null)
            {
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADConfigurationDomainControllers, string.Join <Fqdn>(",", serverSettings.ConfigurationDomainControllers.Values));
            }
            if (serverSettings.PreferredGlobalCatalogs != null)
            {
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADPreferredGlobalCatalogs, string.Join <Fqdn>(",", serverSettings.PreferredGlobalCatalogs.Values));
            }
            if (serverSettings.PreferredDomainControllers != null)
            {
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADPreferredDomainControllers, string.Join <Fqdn>(",", serverSettings.PreferredDomainControllers.ToArray()));
            }
            RunspaceServerSettings runspaceServerSettings = serverSettings as RunspaceServerSettings;

            if (runspaceServerSettings == null)
            {
                CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "RunspaceServerSettings", "null");
                return;
            }
            if (runspaceServerSettings.UserConfigurationDomainController != null)
            {
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADUserConfigurationDomainController, runspaceServerSettings.UserConfigurationDomainController);
            }
            if (runspaceServerSettings.UserPreferredGlobalCatalog != null)
            {
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADUserPreferredGlobalCatalog, runspaceServerSettings.UserConfigurationDomainController);
            }
            if (runspaceServerSettings.UserPreferredDomainControllers != null)
            {
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADUserPreferredDomainControllers, string.Join <Fqdn>(",", runspaceServerSettings.UserPreferredDomainControllers.ToArray()));
            }
        }
示例#11
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     base.InternalProcessRecord();
     if (!this.settingsNotModifiable)
     {
         bool flag = true;
         RunspaceServerSettings runspaceServerSettings = (RunspaceServerSettings)base.ServerSettings;
         if (runspaceServerSettings != null)
         {
             flag = !runspaceServerSettings.Equals(this.modifiedServerSettings);
         }
         if (flag)
         {
             if (base.IsVerboseOn)
             {
                 base.WriteVerbose(Strings.VerboseSaveADServerSettings);
             }
             ExchangePropertyContainer.SetServerSettings(base.SessionState, this.modifiedServerSettings);
             if (base.IsVerboseOn)
             {
                 base.WriteVerbose(Strings.VerboseSaveADServerSettingsSucceed);
             }
         }
         else
         {
             this.WriteWarning(Strings.WarningADServerSettingsUnchanged);
         }
     }
     if (this.ResetSettings)
     {
         if (ExchangePropertyContainer.IsContainerInitialized(base.SessionState))
         {
             ExchangePropertyContainer.SetServerSettings(base.SessionState, null);
         }
         base.SessionState.Variables[ExchangePropertyContainer.ADServerSettingsVarName] = null;
         if (base.IsVerboseOn)
         {
             base.WriteVerbose(Strings.VerboseResetADServerSettingsSucceed);
         }
     }
     TaskLogger.LogExit();
 }
示例#12
0
        protected override ADServerSettings GetCmdletADServerSettings()
        {
            this.fields = base.CurrentTaskContext.InvocationInfo.Fields;
            SwitchParameter switchParameter = this.fields.Contains("IsDatacenter") ? ((SwitchParameter)this.fields["IsDatacenter"]) : new SwitchParameter(false);

            if (!this.fields.Contains(ManageOrganizationTaskBase.ParameterCreateSharedConfig))
            {
                new SwitchParameter(false);
            }
            else
            {
                SwitchParameter switchParameter2 = (SwitchParameter)this.fields[ManageOrganizationTaskBase.ParameterCreateSharedConfig];
            }
            string text  = (string)this.fields["TenantProgramId"];
            string text2 = (string)this.fields["TenantOfferId"];
            AccountPartitionIdParameter accountPartitionIdParameter = (AccountPartitionIdParameter)this.fields["AccountPartition"];
            string value = null;

            if (TopologyProvider.CurrentTopologyMode == TopologyMode.ADTopologyService && switchParameter)
            {
                ADServerSettings serverSettings = ExchangePropertyContainer.GetServerSettings(base.CurrentTaskContext.SessionState);
                if (serverSettings != null && accountPartitionIdParameter != null)
                {
                    PartitionId partitionId = RecipientTaskHelper.ResolvePartitionId(accountPartitionIdParameter, null);
                    if (partitionId != null)
                    {
                        value = serverSettings.PreferredGlobalCatalog(partitionId.ForestFQDN);
                    }
                }
                if (string.IsNullOrEmpty(value) && this.Name != null)
                {
                    if (this.domainBasedADServerSettings == null)
                    {
                        PartitionId partitionId2 = (accountPartitionIdParameter == null) ? PartitionId.LocalForest : RecipientTaskHelper.ResolvePartitionId(accountPartitionIdParameter, null);
                        this.domainBasedADServerSettings = RunspaceServerSettings.CreateGcOnlyRunspaceServerSettings(this.Name.ToLowerInvariant(), partitionId2.ForestFQDN, false);
                    }
                    return(this.domainBasedADServerSettings);
                }
            }
            return(base.GetCmdletADServerSettings());
        }
示例#13
0
        protected override ADServerSettings GetCmdletADServerSettings()
        {
            PropertyBag             fields                  = base.CurrentTaskContext.InvocationInfo.Fields;
            SwitchParameter         switchParameter         = fields.Contains("IsDatacenter") ? ((SwitchParameter)fields["IsDatacenter"]) : new SwitchParameter(false);
            bool                    flag                    = fields.Contains("DomainController");
            OrganizationIdParameter organizationIdParameter = (OrganizationIdParameter)fields["PrimaryOrganization"];
            PartitionId             partitionId             = (organizationIdParameter != null) ? ADAccountPartitionLocator.GetPartitionIdByAcceptedDomainName(organizationIdParameter.RawIdentity) : null;
            string                  value                   = null;
            ADServerSettings        serverSettings          = ExchangePropertyContainer.GetServerSettings(base.CurrentTaskContext.SessionState);

            if (serverSettings != null && partitionId != null)
            {
                value = serverSettings.PreferredGlobalCatalog(partitionId.ForestFQDN);
            }
            if (switchParameter && organizationIdParameter != null && string.IsNullOrEmpty(value) && partitionId != null && !flag)
            {
                if (this.domainBasedADServerSettings == null)
                {
                    this.domainBasedADServerSettings = RunspaceServerSettings.CreateGcOnlyRunspaceServerSettings(organizationIdParameter.RawIdentity.ToLowerInvariant(), partitionId.ForestFQDN, false);
                }
                return(this.domainBasedADServerSettings);
            }
            return(base.GetCmdletADServerSettings());
        }
示例#14
0
        public static LocalizedString GetADServerSettings(string cmdletName, ADServerSettings serverSettings, CultureInfo targetCulture)
        {
            if (serverSettings == null)
            {
                throw new ArgumentNullException("serverSettings");
            }
            StringBuilder stringBuilder = new StringBuilder();

            if (cmdletName != null)
            {
                stringBuilder.Append(Strings.VerboseAdminSessionSettings(cmdletName).ToString(targetCulture));
                stringBuilder.Append(' ');
            }
            stringBuilder.Append(Strings.VerboseAdminSessionSettingsViewForest(serverSettings.ViewEntireForest.ToString()).ToString(targetCulture));
            stringBuilder.Append(", ");
            if (serverSettings.RecipientViewRoot != null)
            {
                stringBuilder.Append(Strings.VerboseAdminSessionSettingsDefaultScope(serverSettings.RecipientViewRoot.ToCanonicalName()).ToString(targetCulture));
                stringBuilder.Append(", ");
            }
            IDictionary <string, Fqdn> configurationDomainControllers = serverSettings.ConfigurationDomainControllers;

            if (configurationDomainControllers.Count > 0)
            {
                stringBuilder.Append(Strings.VerboseAdminSessionSettingsConfigDC(string.Join <Fqdn>(", ", configurationDomainControllers.Values)).ToString(targetCulture));
                stringBuilder.Append(", ");
            }
            IDictionary <string, Fqdn> preferredGlobalCatalogs = serverSettings.PreferredGlobalCatalogs;

            if (preferredGlobalCatalogs.Count > 0)
            {
                stringBuilder.Append(Strings.VerboseAdminSessionSettingsGlobalCatalog(string.Join <Fqdn>(", ", preferredGlobalCatalogs.Values)).ToString(targetCulture));
                stringBuilder.Append(", ");
            }
            MultiValuedProperty <Fqdn> preferredDomainControllers = serverSettings.PreferredDomainControllers;

            if (preferredDomainControllers != null && preferredDomainControllers.Count > 0)
            {
                StringBuilder stringBuilder2 = new StringBuilder("{ ");
                for (int i = 0; i < preferredDomainControllers.Count; i++)
                {
                    stringBuilder2.Append(preferredDomainControllers[i].ToString());
                    if (i + 1 < preferredDomainControllers.Count)
                    {
                        stringBuilder2.Append(", ");
                    }
                }
                stringBuilder2.Append(" }");
                stringBuilder.Append(Strings.VerboseAdminSessionSettingsDCs(stringBuilder2.ToString()).ToString(targetCulture));
            }
            RunspaceServerSettings runspaceServerSettings = serverSettings as RunspaceServerSettings;

            if (runspaceServerSettings != null)
            {
                if (runspaceServerSettings.UserConfigurationDomainController != null)
                {
                    stringBuilder.Append(", ");
                    stringBuilder.Append(Strings.VerboseAdminSessionSettingsUserConfigDC(runspaceServerSettings.UserConfigurationDomainController).ToString(targetCulture));
                }
                if (runspaceServerSettings.UserPreferredGlobalCatalog != null)
                {
                    stringBuilder.Append(", ");
                    stringBuilder.Append(Strings.VerboseAdminSessionSettingsUserGlobalCatalog(runspaceServerSettings.UserPreferredGlobalCatalog).ToString(targetCulture));
                }
                MultiValuedProperty <Fqdn> userPreferredDomainControllers = runspaceServerSettings.UserPreferredDomainControllers;
                if (userPreferredDomainControllers != null && userPreferredDomainControllers.Count > 0)
                {
                    stringBuilder.Append(", ");
                    StringBuilder stringBuilder3 = new StringBuilder("{ ");
                    for (int j = 0; j < userPreferredDomainControllers.Count; j++)
                    {
                        stringBuilder3.Append(userPreferredDomainControllers[j].ToString());
                        if (j + 1 < userPreferredDomainControllers.Count)
                        {
                            stringBuilder3.Append(", ");
                        }
                    }
                    stringBuilder3.Append(" }");
                    stringBuilder.Append(Strings.VerboseAdminSessionSettingsDCs(stringBuilder3.ToString()).ToString(targetCulture));
                }
            }
            return(new LocalizedString(stringBuilder.ToString()));
        }
示例#15
0
        internal static bool GetDomainControllerAffinityForOrganization(OrganizationId orgId, out ADServerInfo preferredDomainController)
        {
            if (orgId == null || orgId.ConfigurationUnit == null || orgId == OrganizationId.ForestWideOrgId)
            {
                preferredDomainController = null;
                return(false);
            }
            ADRunspaceServerSettingsProvider instance = ADRunspaceServerSettingsProvider.GetInstance();
            bool flag;

            preferredDomainController = instance.GetGcFromToken(orgId.PartitionId.ForestFQDN, RunspaceServerSettings.GetTokenForOrganization(orgId), out flag, true);
            return(true);
        }
示例#16
0
        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);
            }
        }