示例#1
0
        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]);
            }
        }
        // Token: 0x06000AFD RID: 2813 RVA: 0x000239C0 File Offset: 0x00021BC0
        private IEnumerable <ExchangeConfigurationUnit> GetConfigurationUnits(IConfigurationSession tenantConfigurationSession, string organizationFilter)
        {
            if (string.IsNullOrEmpty(organizationFilter))
            {
                throw new ArgumentException("Filter must contain a non-empty value", "organizationFilter");
            }
            QueryFilter filter = base.CreateWildcardFilter(ADObjectSchema.Name, organizationFilter);
            ADObjectId  configurationUnitsRoot = ADSession.GetConfigurationUnitsRoot(this.AccountPartition.ForestFQDN);
            ADPagedReader <ADRawEntry> source  = tenantConfigurationSession.FindPagedADRawEntry(configurationUnitsRoot, QueryScope.OneLevel, filter, null, 0, new ADPropertyDefinition[]
            {
                ADObjectSchema.Id
            });
            IEnumerable <ADObjectId> source2 = from tenant in source
                                               select tenant.Id.GetChildId("Configuration");

            Result <ExchangeConfigurationUnit>[] source3 = tenantConfigurationSession.ReadMultiple <ExchangeConfigurationUnit>(source2.ToArray <ADObjectId>());
            return(from result in source3
                   select result.Data into cu
                   where null != cu
                   select cu);
        }
 internal static EphemeralIdTable.NamingContext GetNamingContext(ADObjectId id)
 {
     if (id.IsDescendantOf(ADSession.GetConfigurationNamingContext(id.GetPartitionId().ForestFQDN)))
     {
         if (!ADSession.IsTenantIdentity(id, id.GetPartitionId().ForestFQDN))
         {
             return(EphemeralIdTable.NamingContext.Config);
         }
         return(EphemeralIdTable.NamingContext.TenantConfig);
     }
     else
     {
         if (!ADSession.IsTenantIdentity(id, id.GetPartitionId().ForestFQDN))
         {
             return(EphemeralIdTable.NamingContext.Domain);
         }
         if (!id.IsDescendantOf(ADSession.GetConfigurationUnitsRoot(id.GetPartitionId().ForestFQDN)))
         {
             return(EphemeralIdTable.NamingContext.Domain);
         }
         return(EphemeralIdTable.NamingContext.TenantConfig);
     }
 }
 protected override ADObjectId GetBaseContainer()
 {
     return(ADSession.GetConfigurationUnitsRoot(new PartitionId(this.AccountPartition).ForestFQDN));
 }
示例#5
0
        internal ExchangeConfigurationUnit GetConfigurationUnit(string orgName)
        {
            if (string.IsNullOrEmpty(orgName))
            {
                throw new ArgumentException("OrgName must contain a non-empty value", "orgName");
            }
            ExchangeConfigurationUnit exchangeConfigurationUnit = null;

            try
            {
                ADSessionSettings           adsessionSettings          = ADSessionSettings.FromTenantCUName(orgName);
                ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, adsessionSettings, 866, "GetConfigurationUnit", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\ADIdParameter.cs");
                adsessionSettings.TenantConsistencyMode = TenantConsistencyMode.IncludeRetiredTenants;
                exchangeConfigurationUnit = tenantConfigurationSession.GetExchangeConfigurationUnitByName(orgName);
            }
            catch (CannotResolveTenantNameException)
            {
            }
            SmtpDomain smtpDomain = null;

            if (exchangeConfigurationUnit == null && SmtpDomain.TryParse(orgName, out smtpDomain))
            {
                try
                {
                    ADSessionSettings           sessionSettings            = ADSessionSettings.FromTenantAcceptedDomain(orgName);
                    ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, sessionSettings, 890, "GetConfigurationUnit", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\ADIdParameter.cs");
                    exchangeConfigurationUnit = tenantConfigurationSession.GetExchangeConfigurationUnitByNameOrAcceptedDomain(orgName);
                }
                catch (CannotResolveTenantNameException)
                {
                }
            }
            Guid externalDirectoryOrganizationId;

            if (exchangeConfigurationUnit == null && GuidHelper.TryParseGuid(orgName, out externalDirectoryOrganizationId))
            {
                try
                {
                    PartitionId                 partitionIdByExternalDirectoryOrganizationId = ADAccountPartitionLocator.GetPartitionIdByExternalDirectoryOrganizationId(externalDirectoryOrganizationId);
                    ADSessionSettings           sessionSettings2           = ADSessionSettings.FromAllTenantsPartitionId(partitionIdByExternalDirectoryOrganizationId);
                    ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, sessionSettings2, 911, "GetConfigurationUnit", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\ADIdParameter.cs");
                    QueryFilter                 filter = new ComparisonFilter(ComparisonOperator.Equal, ExchangeConfigurationUnitSchema.ExternalDirectoryOrganizationId, externalDirectoryOrganizationId.ToString());
                    ExchangeConfigurationUnit[] array  = tenantConfigurationSession.Find <ExchangeConfigurationUnit>(ADSession.GetConfigurationUnitsRoot(partitionIdByExternalDirectoryOrganizationId.ForestFQDN), QueryScope.SubTree, filter, null, 0);
                    if (array.Length == 1)
                    {
                        exchangeConfigurationUnit = array[0];
                    }
                }
                catch (CannotResolveExternalDirectoryOrganizationIdException)
                {
                }
            }
            return(exchangeConfigurationUnit);
        }