Exemple #1
0
        internal static void InitializeForestModeFlagForLocalForest()
        {
            string localForestFqdn = TopologyProvider.LocalForestFqdn;

            try
            {
                ADSession.IsTenantConfigInDomainNC(localForestFqdn);
            }
            catch (OrgContainerNotFoundException)
            {
                if (Globals.IsDatacenter)
                {
                    if (Globals.IsMicrosoftHostedOnly)
                    {
                        InternalDirectoryRootOrganizationCache.InitializeForestModeFlagForSetup(localForestFqdn, TenantCULocation.DomainNC);
                    }
                    else
                    {
                        InternalDirectoryRootOrganizationCache.InitializeForestModeFlagForSetup(localForestFqdn, TenantCULocation.ConfigNC);
                    }
                }
                else
                {
                    InternalDirectoryRootOrganizationCache.InitializeForestModeFlagForSetup(localForestFqdn, TenantCULocation.ConfigNC);
                }
            }
            finally
            {
                InternalDirectoryRootOrganizationCache.GetTenantCULocation(localForestFqdn);
            }
        }
Exemple #2
0
        internal static ADObjectId GetRootOrgContainerId(string partitionFqdn, string domainController, NetworkCredential credential)
        {
            ArgumentValidator.ThrowIfNullOrEmpty("partitionFqdn", partitionFqdn);
            ADObjectId rootOrgContainerId = InternalDirectoryRootOrganizationCache.GetRootOrgContainerId(partitionFqdn);

            if (rootOrgContainerId != null)
            {
                return(rootOrgContainerId);
            }
            Organization rootOrgContainer = ADSystemConfigurationSession.GetRootOrgContainer(partitionFqdn, domainController, credential);

            if (rootOrgContainer == null)
            {
                return(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest());
            }
            return(rootOrgContainer.Id);
        }
Exemple #3
0
        internal static Organization GetRootOrgContainer(string partitionFqdn, string domainController, NetworkCredential credential)
        {
            bool       flag = string.IsNullOrEmpty(domainController);
            ADObjectId adobjectId;

            if (!PartitionId.IsLocalForestPartition(partitionFqdn))
            {
                adobjectId = ADSession.GetConfigurationNamingContext(partitionFqdn);
            }
            else if (flag)
            {
                adobjectId = ADSession.GetConfigurationNamingContextForLocalForest();
            }
            else
            {
                adobjectId = ADSession.GetConfigurationNamingContext(domainController, credential);
            }
            ADSessionSettings             sessionSettings = ADSessionSettings.FromRootOrgBootStrapSession(adobjectId);
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.NonCacheSessionFactory.CreateTopologyConfigurationSession(domainController, true, ConsistencyMode.PartiallyConsistent, flag ? null : credential, sessionSettings, 226, "GetRootOrgContainer", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\ADSystemConfigurationSession.cs");

            Organization[] array = topologyConfigurationSession.Find <Organization>(adobjectId, QueryScope.SubTree, null, null, 1);
            if (array != null && array.Length > 0)
            {
                if (string.IsNullOrEmpty(domainController) && credential == null)
                {
                    InternalDirectoryRootOrganizationCache.PopulateCache(partitionFqdn, array[0]);
                }
                return(array[0]);
            }
            if (flag && (Globals.IsDatacenter || PartitionId.IsLocalForestPartition(partitionFqdn)))
            {
                throw new OrgContainerNotFoundException();
            }
            RootDse rootDse = topologyConfigurationSession.GetRootDse();

            if (rootDse.ConfigurationNamingContext.Equals(ADSession.GetConfigurationNamingContext(partitionFqdn)))
            {
                throw new OrgContainerNotFoundException();
            }
            return(null);
        }
Exemple #4
0
        internal static bool IsTenantConfigInDomainNC(string partitionFqdn)
        {
            TenantCULocation tenantCULocation = InternalDirectoryRootOrganizationCache.GetTenantCULocation(partitionFqdn);

            if (tenantCULocation == TenantCULocation.Undefined)
            {
                if (Globals.IsDatacenter)
                {
                    ADSystemConfigurationSession.GetRootOrgContainer(partitionFqdn, null, null);
                    tenantCULocation = InternalDirectoryRootOrganizationCache.GetTenantCULocation(partitionFqdn);
                }
                else
                {
                    tenantCULocation = TenantCULocation.ConfigNC;
                    if (PartitionId.IsLocalForestPartition(partitionFqdn))
                    {
                        InternalDirectoryRootOrganizationCache.InitializeForestModeFlagForSetup(partitionFqdn, tenantCULocation);
                    }
                }
            }
            return(tenantCULocation == TenantCULocation.DomainNC);
        }