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); }