Exemplo n.º 1
0
        // Token: 0x0600002B RID: 43 RVA: 0x000024F0 File Offset: 0x000006F0
        public static string ResolveFqdn(string shortNodeName, bool throwException)
        {
            string    fqdn = null;
            Exception ex   = SharedHelper.RunADOperationEx(delegate(object param0, EventArgs param1)
            {
                IADToplogyConfigurationSession iadtoplogyConfigurationSession = ADSessionFactory.CreateIgnoreInvalidRootOrgSession(true);
                iadtoplogyConfigurationSession.UseConfigNC      = false;
                iadtoplogyConfigurationSession.UseGlobalCatalog = true;
                IADComputer iadcomputer = iadtoplogyConfigurationSession.FindComputerByHostName(shortNodeName);
                if (iadcomputer != null && !string.IsNullOrEmpty(iadcomputer.DnsHostName))
                {
                    fqdn = iadcomputer.DnsHostName;
                    return;
                }
                if (throwException)
                {
                    throw new AmGetFqdnFailedNotFoundException(shortNodeName);
                }
                AmTrace.Error("FQDN resolution of the short name {0} failed. Could not find valid DNS hostname from ADComputer query.", new object[]
                {
                    shortNodeName
                });
                fqdn = AmServerNameCache.GetFqdnWithLocalDomainSuffix(shortNodeName);
            });

            if (ex != null)
            {
                if (throwException)
                {
                    throw new AmGetFqdnFailedADErrorException(shortNodeName, ex.Message, ex);
                }
                AmTrace.Error("FQDN resolution of the short name {0} failed. Error: {1}", new object[]
                {
                    shortNodeName,
                    ex.Message
                });
                fqdn = AmServerNameCache.GetFqdnWithLocalDomainSuffix(shortNodeName);
            }
            return(fqdn);
        }
Exemplo n.º 2
0
        // Token: 0x06000030 RID: 48 RVA: 0x00002874 File Offset: 0x00000A74
        public void PopulateForDag()
        {
            Dictionary <string, AmServerNameCache.CacheEntry> dictionary = new Dictionary <string, AmServerNameCache.CacheEntry>(16, MachineName.Comparer);
            Exception ex = SharedHelper.RunADOperationEx(delegate(object param0, EventArgs param1)
            {
                IADToplogyConfigurationSession iadtoplogyConfigurationSession = ADSessionFactory.CreateIgnoreInvalidRootOrgSession(true);
                Exception ex2;
                IADDatabaseAvailabilityGroup localServerDatabaseAvailabilityGroup = DirectoryHelper.GetLocalServerDatabaseAvailabilityGroup(iadtoplogyConfigurationSession, out ex2);
                if (ex2 != null)
                {
                    AmServerNameCache.Tracer.TraceError <Exception>(0L, "PopulateForDag failed to get DAG: {0}", ex2);
                    return;
                }
                if (localServerDatabaseAvailabilityGroup != null)
                {
                    iadtoplogyConfigurationSession.UseConfigNC      = false;
                    iadtoplogyConfigurationSession.UseGlobalCatalog = true;
                    MultiValuedProperty <ADObjectId> servers        = localServerDatabaseAvailabilityGroup.Servers;
                    if (servers != null)
                    {
                        foreach (ADObjectId adobjectId in servers)
                        {
                            IADComputer iadcomputer = iadtoplogyConfigurationSession.FindComputerByHostName(adobjectId.Name);
                            if (iadcomputer != null && !string.IsNullOrEmpty(iadcomputer.DnsHostName))
                            {
                                AmServerNameCache.CacheEntry cacheEntry = new AmServerNameCache.CacheEntry();
                                cacheEntry.ExpiryTime = ExDateTime.Now + this.TimeToLive;
                                cacheEntry.Fqdn       = iadcomputer.DnsHostName;
                            }
                            else
                            {
                                AmServerNameCache.Tracer.TraceError <ADObjectId>(0L, "PopulateForDag could not map server {0}", adobjectId);
                            }
                        }
                    }
                }
            });

            if (ex != null)
            {
                AmServerNameCache.Tracer.TraceError <Exception>(0L, "PopulateForDag did not replace cache because: {0}", ex);
                return;
            }
            if (dictionary != null)
            {
                AmServerNameCache.Tracer.TraceDebug(0L, "PopulateForDag replaced the cache");
                try
                {
                    this.m_rwLock.EnterWriteLock();
                    this.m_cache = dictionary;
                }
                finally
                {
                    try
                    {
                        this.m_rwLock.ExitWriteLock();
                    }
                    catch (SynchronizationLockException)
                    {
                    }
                }
            }
        }