コード例 #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);
        }
コード例 #2
0
        public override string GetFqdn(string shortNodeName, bool throwException)
        {
            string result;

            try
            {
                ExTraceGlobals.FaultInjectionTracer.TraceTest(3081121085U);
                result = base.GetFqdn(shortNodeName, true);
            }
            catch (AmServerNameResolveFqdnException ex)
            {
                AmTrace.Error("FQDN resolution of the short name {0} failed. Error: {1}", new object[]
                {
                    shortNodeName,
                    ex.Message
                });
                ReplayEventLogConstants.Tuple_FqdnResolutionFailure.LogEvent(ExTraceGlobals.ActiveManagerTracer.GetHashCode().ToString(), new object[]
                {
                    shortNodeName,
                    ex.Message
                });
                result = AmServerNameCache.GetFqdnWithLocalDomainSuffix(shortNodeName);
            }
            return(result);
        }
コード例 #3
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);
        }