Beispiel #1
0
        // Token: 0x0600002E RID: 46 RVA: 0x000025F4 File Offset: 0x000007F4
        public virtual string GetFqdn(string shortNodeName, bool throwException)
        {
            if (SharedHelper.StringIEquals(shortNodeName, "localhost") || SharedHelper.StringIEquals(shortNodeName, MachineName.Local))
            {
                return(AmServerName.LocalComputerName.Fqdn);
            }
            AmServerNameCache.CacheEntry cacheEntry = null;
            bool flag = false;

            try
            {
                this.m_rwLock.EnterReadLock();
                if (this.m_cache != null)
                {
                    flag = true;
                    if (this.m_cache.TryGetValue(shortNodeName, out cacheEntry) && cacheEntry.ExpiryTime > ExDateTime.Now)
                    {
                        return(cacheEntry.Fqdn);
                    }
                }
            }
            finally
            {
                try
                {
                    this.m_rwLock.ExitReadLock();
                }
                catch (SynchronizationLockException)
                {
                }
            }
            string text = AmServerNameCache.ResolveFqdn(shortNodeName, throwException);

            if (!flag)
            {
                return(text);
            }
            try
            {
                this.m_rwLock.EnterWriteLock();
                if (!this.m_cache.TryGetValue(shortNodeName, out cacheEntry))
                {
                    cacheEntry = new AmServerNameCache.CacheEntry();
                    this.m_cache.Add(shortNodeName, cacheEntry);
                }
                cacheEntry.ExpiryTime = ExDateTime.Now + this.TimeToLive;
                cacheEntry.Fqdn       = text;
            }
            finally
            {
                try
                {
                    this.m_rwLock.ExitWriteLock();
                }
                catch (SynchronizationLockException)
                {
                }
            }
            return(text);
        }
Beispiel #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)
                    {
                    }
                }
            }
        }