private ADServerInfo GetDirectoryServer(string partitionFqdn, ADRole role) { ExTraceGlobals.TopologyProviderTracer.TraceDebug <string, ADRole>((long)this.GetHashCode(), "GetDirectoryServer PartitionFqdn {0}. Role {1}", partitionFqdn, role); LocatorFlags locatorFlags = LocatorFlags.ForceRediscovery | LocatorFlags.DirectoryServicesRequired | LocatorFlags.ReturnDnsName; string text = partitionFqdn; if (ADRole.GlobalCatalog == role) { ADObjectId rootDomainNamingContext = base.GetRootDomainNamingContext(partitionFqdn); ADObjectId domainNamingContext = base.GetDomainNamingContext(partitionFqdn); if (!rootDomainNamingContext.DistinguishedName.Equals(domainNamingContext.DistinguishedName, StringComparison.OrdinalIgnoreCase)) { text = NativeHelpers.CanonicalNameFromDistinguishedName(rootDomainNamingContext.DistinguishedName); } locatorFlags |= LocatorFlags.GCRequired; } ExTraceGlobals.TopologyProviderTracer.TraceDebug <string, string, LocatorFlags>((long)this.GetHashCode(), "GetDirectoryServer. Partition Fqdn {0} Parent Domain {1}. Flags {2}", partitionFqdn, text, locatorFlags); ADServerInfo serverInfo = new ADServerInfo(null, text, (ADRole.GlobalCatalog == role) ? 3268 : 389, null, 100, AuthType.Kerberos, true); PooledLdapConnection pooledLdapConnection = null; ADServerInfo adserverInfo = null; try { pooledLdapConnection = LdapConnectionPool.CreateOneTimeConnection(null, serverInfo, locatorFlags); if (!string.IsNullOrEmpty(pooledLdapConnection.SessionOptions.HostName)) { adserverInfo = pooledLdapConnection.ADServerInfo.CloneWithServerNameResolved(pooledLdapConnection.SessionOptions.HostName); } ExTraceGlobals.TopologyProviderTracer.TraceDebug <string, string>((long)this.GetHashCode(), "GetDirectoryServer. Partition Fqdn {0}. Server {1}", partitionFqdn, pooledLdapConnection.SessionOptions.HostName ?? string.Empty); } finally { if (pooledLdapConnection != null) { pooledLdapConnection.ReturnToPool(); } } string text2; LocalizedString localizedString; if (adserverInfo != null && SuitabilityVerifier.IsServerSuitableIgnoreExceptions(adserverInfo.Fqdn, ADRole.GlobalCatalog == role, null, out text2, out localizedString)) { return(adserverInfo); } return(LdapTopologyProvider.FindDirectoryServerForForestOrDomain(text, null, ADRole.GlobalCatalog == role)); }
public override ADServerInfo GetRemoteServerFromDomainFqdn(string domainFqdn, NetworkCredential credential) { ExTraceGlobals.TopologyProviderTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Need server from remote domain {0} {1} credentials.", domainFqdn, (credential == null) ? "without" : "with"); return(LdapTopologyProvider.FindDirectoryServerForForestOrDomain(domainFqdn, credential, false)); }