Exemplo n.º 1
0
        public static ADDomain FindExternalDomain(string fqdn, NetworkCredential credential)
        {
            if (string.IsNullOrEmpty(fqdn))
            {
                throw new ArgumentNullException("fqdn");
            }
            if (credential == null)
            {
                throw new ArgumentNullException("credential");
            }
            if (string.IsNullOrEmpty(credential.UserName))
            {
                throw new ArgumentException("User name must be provided in the credential argument to perform this operation.");
            }
            ADServerInfo          remoteServerFromDomainFqdn           = TopologyProvider.GetInstance().GetRemoteServerFromDomainFqdn(fqdn, credential);
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(remoteServerFromDomainFqdn.Fqdn, true, ConsistencyMode.FullyConsistent, credential, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(Datacenter.IsMicrosoftHostedOnly(true) ? new PartitionId(remoteServerFromDomainFqdn.Fqdn) : PartitionId.LocalForest), 316, "FindExternalDomain", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\ADForest.cs");

            tenantOrTopologyConfigurationSession.UseConfigNC         = false;
            tenantOrTopologyConfigurationSession.EnforceDefaultScope = false;
            ADDomain[] array = tenantOrTopologyConfigurationSession.Find <ADDomain>(new ADObjectId(NativeHelpers.DistinguishedNameFromCanonicalName(fqdn)), QueryScope.Base, null, null, 1);
            if (array == null || array.Length <= 0)
            {
                throw new ADExternalException(DirectoryStrings.ExceptionADTopologyNoSuchDomain(fqdn));
            }
            return(array[0]);
        }
Exemplo n.º 2
0
 public static ADForest GetForest(string forestFqdn, NetworkCredential credentials)
 {
     if (string.IsNullOrEmpty(forestFqdn))
     {
         throw new ArgumentNullException("forestFqdn");
     }
     if (ADForest.IsLocalForestFqdn(forestFqdn))
     {
         if (credentials != null)
         {
             throw new ArgumentException("The use of credentials is not supported for the local forest '" + forestFqdn + "'");
         }
         return(ADForest.GetLocalForest());
     }
     else
     {
         PartitionId partitionId = new PartitionId(forestFqdn);
         if (ADAccountPartitionLocator.IsKnownPartition(partitionId))
         {
             return(ADForest.GetForest(partitionId));
         }
         ADServerInfo remoteServerFromDomainFqdn = TopologyProvider.GetInstance().GetRemoteServerFromDomainFqdn(forestFqdn, credentials);
         return(new ADForest(forestFqdn, remoteServerFromDomainFqdn.Fqdn, null, credentials, false));
     }
 }
Exemplo n.º 3
0
        public static ITopologyConfigurationSession CreateRemoteForestSession(string fqdn, NetworkCredential credential)
        {
            if (string.IsNullOrEmpty(fqdn))
            {
                throw new ArgumentNullException("fqdn");
            }
            if (credential != null && (string.IsNullOrEmpty(credential.UserName) || string.IsNullOrEmpty(credential.Password)))
            {
                throw new ArgumentException("credential");
            }
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(null, true, ConsistencyMode.PartiallyConsistent, credential, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(new PartitionId(fqdn)), 69, "CreateRemoteForestSession", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\ADSystemConfigurationSession.cs");
            ADServerInfo remoteServerFromDomainFqdn = TopologyProvider.GetInstance().GetRemoteServerFromDomainFqdn(fqdn, credential);

            topologyConfigurationSession.DomainController    = remoteServerFromDomainFqdn.Fqdn;
            topologyConfigurationSession.EnforceDefaultScope = false;
            return(topologyConfigurationSession);
        }
Exemplo n.º 4
0
        internal static bool GetDomainControllerAffinityForOrganization(OrganizationId orgId, out ADServerInfo preferredDomainController)
        {
            if (orgId == null || orgId.ConfigurationUnit == null || orgId == OrganizationId.ForestWideOrgId)
            {
                preferredDomainController = null;
                return(false);
            }
            ADRunspaceServerSettingsProvider instance = ADRunspaceServerSettingsProvider.GetInstance();
            bool flag;

            preferredDomainController = instance.GetGcFromToken(orgId.PartitionId.ForestFQDN, RunspaceServerSettings.GetTokenForOrganization(orgId), out flag, true);
            return(true);
        }