// Token: 0x06000599 RID: 1433 RVA: 0x0001EFDC File Offset: 0x0001D1DC
 internal virtual bool IsFailoverRequired()
 {
     if (this.EnforceIsUpdatableByADSession && !this.IsUpdatableByADSession)
     {
         return(false);
     }
     foreach (Fqdn fqdn in this.serversDown)
     {
         lock (this.syncRoot)
         {
             IEnumerable <Fqdn>[] array = new IEnumerable <Fqdn>[]
             {
                 this.configurationDomainController.Values,
                 this.preferredGlobalCatalog.Values,
                 this.PreferredDomainControllers
             };
             foreach (IEnumerable <Fqdn> enumerable in array)
             {
                 foreach (Fqdn fqdn2 in enumerable)
                 {
                     string text = fqdn2;
                     if (text.Equals(fqdn))
                     {
                         return(true);
                     }
                 }
             }
         }
         if (ADRunspaceServerSettingsProvider.GetInstance().IsServerKnown(fqdn))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #2
0
 // Token: 0x06000509 RID: 1289 RVA: 0x0001C82C File Offset: 0x0001AA2C
 internal static ADRunspaceServerSettingsProvider GetInstance()
 {
     if (ADRunspaceServerSettingsProvider.staticInstance == null)
     {
         ADRunspaceServerSettingsProvider value = new ADRunspaceServerSettingsProvider();
         Interlocked.CompareExchange <ADRunspaceServerSettingsProvider>(ref ADRunspaceServerSettingsProvider.staticInstance, value, null);
     }
     return(ADRunspaceServerSettingsProvider.staticInstance);
 }
        internal static RunspaceServerSettings CreateRunspaceServerSettings(string partitionFqdn, bool forestWideAffinityRequested = false)
        {
            ADRunspaceServerSettingsProvider instance = ADRunspaceServerSettingsProvider.GetInstance();
            bool                   flag;
            ADServerInfo           gcFromToken            = instance.GetGcFromToken(partitionFqdn, null, out flag, forestWideAffinityRequested);
            RunspaceServerSettings runspaceServerSettings = new RunspaceServerSettings(partitionFqdn, gcFromToken, instance.GetConfigDc(partitionFqdn));

            if (flag)
            {
                runspaceServerSettings.AddPreferredDC(gcFromToken);
            }
            return(runspaceServerSettings);
        }
        internal static RunspaceServerSettings CreateGcOnlyRunspaceServerSettings(string token, string partitionFqdn, bool forestWideAffinityRequested = false)
        {
            if (string.IsNullOrEmpty(token))
            {
                throw new ArgumentNullException("token");
            }
            if (string.IsNullOrEmpty(partitionFqdn))
            {
                throw new ArgumentNullException("partitionFqdn");
            }
            ADRunspaceServerSettingsProvider instance = ADRunspaceServerSettingsProvider.GetInstance();

            ExTraceGlobals.ServerSettingsProviderTracer.TraceDebug <string>((long)instance.GetHashCode(), "GetGcOnlyRunspaceServerSettings for token {0}", token);
            bool         flag;
            ADServerInfo gcFromToken = instance.GetGcFromToken(partitionFqdn, token, out flag, forestWideAffinityRequested);

            return(new RunspaceServerSettings(partitionFqdn, gcFromToken, token)
            {
                ViewEntireForest = true
            });
        }
        // Token: 0x0600059C RID: 1436 RVA: 0x0001F25C File Offset: 0x0001D45C
        internal virtual bool TryFailover(out ADServerSettings newServerSettings, out string failToFailOverReason, bool forestWideAffinityRequested = false)
        {
            if (this.EnforceIsUpdatableByADSession && !this.IsUpdatableByADSession)
            {
                throw new NotSupportedException("TryFailover is not supported on " + base.GetType().Name);
            }
            bool result = true;

            failToFailOverReason = null;
            ADServerSettings adserverSettings         = (ADServerSettings)this.Clone();
            ADRunspaceServerSettingsProvider instance = ADRunspaceServerSettingsProvider.GetInstance();
            string token = adserverSettings.Token;

            foreach (Fqdn fqdn in adserverSettings.serversDown)
            {
                adserverSettings.RemovePreferredDC(fqdn);
                try
                {
                    List <string> list = new List <string>();
                    foreach (KeyValuePair <string, Fqdn> keyValuePair in adserverSettings.preferredGlobalCatalog)
                    {
                        if (string.Equals(fqdn, keyValuePair.Value, StringComparison.OrdinalIgnoreCase))
                        {
                            string key = keyValuePair.Key;
                            list.Add(key);
                        }
                    }
                    foreach (string partitionFqdn in list)
                    {
                        ExTraceGlobals.ServerSettingsProviderTracer.TraceDebug <string>((long)instance.GetHashCode(), "GetGcOnlyRunspaceServerSettings for token {0}", token ?? "<null>");
                        bool         flag;
                        ADServerInfo gcFromToken = instance.GetGcFromToken(partitionFqdn, token, out flag, forestWideAffinityRequested);
                        adserverSettings.SetPreferredGlobalCatalog(partitionFqdn, gcFromToken);
                        if (adserverSettings.Token != null)
                        {
                            adserverSettings.SetConfigurationDomainController(partitionFqdn, gcFromToken);
                        }
                        if (adserverSettings.Token != null || flag)
                        {
                            adserverSettings.AddPreferredDC(gcFromToken);
                        }
                    }
                }
                catch (ADTransientException ex)
                {
                    failToFailOverReason = ex.ToString();
                    result = false;
                }
                catch (ADExternalException ex2)
                {
                    failToFailOverReason = ex2.ToString();
                    result = false;
                }
                if (token == null)
                {
                    List <string> list2 = new List <string>();
                    foreach (KeyValuePair <string, Fqdn> keyValuePair2 in adserverSettings.configurationDomainController)
                    {
                        if (string.Equals(fqdn, keyValuePair2.Value, StringComparison.OrdinalIgnoreCase))
                        {
                            string key2 = keyValuePair2.Key;
                            list2.Add(key2);
                        }
                    }
                    foreach (string text in list2)
                    {
                        ADServerInfo configDc = instance.GetConfigDc(text);
                        if (configDc != null)
                        {
                            adserverSettings.SetConfigurationDomainController(text, configDc);
                        }
                    }
                }
            }
            adserverSettings.serversDown.Clear();
            newServerSettings = adserverSettings;
            return(result);
        }