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); }
public Organization GetOrgContainer() { ADObjectId adobjectId = null; if (base.SessionSettings.ConfigReadScope != null) { adobjectId = base.SessionSettings.ConfigReadScope.Root; } Organization[] array; if (adobjectId == null) { if (Globals.IsDatacenter) { Organization organization = (Organization)ADSystemConfigurationSession.GetRootOrgContainer(base.SessionSettings.GetAccountOrResourceForestFqdn(), base.DomainController, base.NetworkCredential).Clone(); organization.SetIsReadOnly(false); organization.m_Session = this; return(organization); } array = base.Find <Organization>(null, QueryScope.SubTree, null, null, 2); } else if (adobjectId.Parent.Parent.Equals(ADSession.GetConfigurationUnitsRoot(base.SessionSettings.GetAccountOrResourceForestFqdn()))) { array = base.Find <ExchangeConfigurationUnit>(adobjectId, QueryScope.Base, null, null, 1); } else { array = base.Find <ExchangeConfigurationUnit>(adobjectId, QueryScope.SubTree, null, null, 2); } if (array == null || array.Length == 0) { if (adobjectId == null) { throw new OrgContainerNotFoundException(); } throw new TenantOrgContainerNotFoundException(adobjectId.ToString()); } else { if (array.Length > 1) { throw new OrgContainerAmbiguousException(); } return(array[0]); } }