private static ExchangeConfigurationUnit RetrieveLocalTempateTenant()
        {
            ADPagedReader <ExchangeConfigurationUnit> adpagedReader = TemplateTenantConfiguration.FindAllTempateTenants(TemplateTenantConfiguration.ProgramId, TemplateTenantConfiguration.OfferId, PartitionId.LocalForest);

            ExchangeConfigurationUnit[] array = adpagedReader.ReadAllPages();
            switch (array.Length)
            {
            case 0:
                return(null);

            case 1:
                return(array[0]);

            default:
            {
                Array.Sort <ExchangeConfigurationUnit>(array, new Comparison <ExchangeConfigurationUnit>(SharedConfiguration.CompareBySharedConfigurationInfo));
                ExchangeConfigurationUnit result = array[0];
                foreach (ExchangeConfigurationUnit exchangeConfigurationUnit in array)
                {
                    if (!(exchangeConfigurationUnit.SharedConfigurationInfo != null) || ((IComparable)ServerVersion.InstalledVersion).CompareTo(exchangeConfigurationUnit.SharedConfigurationInfo.CurrentVersion) < 0)
                    {
                        break;
                    }
                    result = exchangeConfigurationUnit;
                }
                return(result);
            }
            }
        }
 private static void RetrieveLocalTempateUserContext()
 {
     if (TemplateTenantConfiguration.cachedTemplateUser == null)
     {
         ExchangeConfigurationUnit localTemplateTenant = TemplateTenantConfiguration.GetLocalTemplateTenant();
         if (localTemplateTenant == null)
         {
             throw new ADTransientException(DirectoryStrings.CannotFindTemplateTenant);
         }
         ADSessionSettings adsessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), localTemplateTenant.OrganizationId, null, false);
         adsessionSettings.ForceADInTemplateScope = true;
         ITenantRecipientSession tenantRecipientSession = DirectorySessionFactory.Default.CreateTenantRecipientSession(false, ConsistencyMode.IgnoreInvalid, adsessionSettings, 121, "RetrieveLocalTempateUserContext", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\TemplateTenantConfiguration.cs");
         QueryFilter             filter = new AndFilter(new QueryFilter[]
         {
             new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.ObjectClass, ADUser.MostDerivedClass),
             new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.RecipientTypeDetailsValue, RecipientTypeDetails.MailboxPlan)
         });
         ADUser[] array = tenantRecipientSession.FindADUser(null, QueryScope.OneLevel, filter, null, 1);
         if (array == null || array.Length == 0)
         {
             new ADTransientException(DirectoryStrings.CannotFindTemplateUser(localTemplateTenant.OrganizationalUnitRoot.DistinguishedName));
         }
         array[0].RecipientTypeDetails                      = RecipientTypeDetails.UserMailbox;
         array[0].RecipientDisplayType                      = new RecipientDisplayType?(RecipientDisplayType.MailboxUser);
         array[0].MasterAccountSid                          = null;
         array[0].AcceptMessagesOnlyFrom                    = null;
         array[0].UseDatabaseQuotaDefaults                  = new bool?(false);
         array[0].ExchangeUserAccountControl                = UserAccountControlFlags.None;
         TemplateTenantConfiguration.cachedTemplateUser     = array[0];
         TemplateTenantConfiguration.cachedTemplateUserSd   = tenantRecipientSession.ReadSecurityDescriptorBlob(array[0].Id);
         TemplateTenantConfiguration.cachedRecipientSession = tenantRecipientSession;
     }
 }
 internal static SecurityDescriptor GetTemplateUserSecurityDescriptorBlob()
 {
     if (TemplateTenantConfiguration.cachedTemplateUser == null)
     {
         TemplateTenantConfiguration.RetrieveLocalTempateUserContext();
     }
     return(TemplateTenantConfiguration.cachedTemplateUserSd);
 }
 internal static ADUser GetLocalTempateUser()
 {
     if (TemplateTenantConfiguration.cachedTemplateUser == null)
     {
         TemplateTenantConfiguration.RetrieveLocalTempateUserContext();
     }
     return(TemplateTenantConfiguration.cachedTemplateUser);
 }
 internal static ITenantRecipientSession GetTempateTenantRecipientSession()
 {
     if (TemplateTenantConfiguration.cachedTemplateUser == null)
     {
         TemplateTenantConfiguration.RetrieveLocalTempateUserContext();
     }
     return(TemplateTenantConfiguration.cachedRecipientSession);
 }
 internal static ExchangeConfigurationUnit GetLocalTemplateTenant()
 {
     if (TemplateTenantConfiguration.cachedTemplateTenant == null)
     {
         TemplateTenantConfiguration.cachedTemplateTenant = TemplateTenantConfiguration.RetrieveLocalTempateTenant();
     }
     return(TemplateTenantConfiguration.cachedTemplateTenant);
 }
        // Token: 0x0600061B RID: 1563 RVA: 0x000211EC File Offset: 0x0001F3EC
        internal static bool UseAggregateSession(ADSessionSettings sessionSettings)
        {
            ADServerSettings externalServerSettings = ADSessionSettings.ExternalServerSettings;
            ADDriverContext  processADContext       = ADSessionSettings.GetProcessADContext();
            bool             flag  = processADContext != null && processADContext.Mode == ContextMode.Setup;
            bool             flag2 = externalServerSettings != null && externalServerSettings.ForceADInTemplateScope;
            bool             flag3 = !ConfigBase <AdDriverConfigSchema> .GetConfig <bool>("ConsumerMailboxScenarioDisabled");

            return(flag3 && TemplateTenantConfiguration.IsTemplateTenant(sessionSettings.CurrentOrganizationId) && !sessionSettings.ForceADInTemplateScope && !flag2 && !flag);
        }
示例#8
0
 internal static ADSessionSettings FromConsumerOrganization()
 {
     return(ADSessionSettings.InvokeWithAPILogging <ADSessionSettings>(delegate
     {
         ExchangeConfigurationUnit localTemplateTenant = TemplateTenantConfiguration.GetLocalTemplateTenant();
         if (localTemplateTenant == null)
         {
             throw new ADTransientException(DirectoryStrings.CannotFindTemplateTenant);
         }
         return ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(localTemplateTenant.OrganizationId);
     }, "FromConsumerOrganization"));
 }
        // Token: 0x06000329 RID: 809 RVA: 0x00011358 File Offset: 0x0000F558
        private static TenantPartitionCacheItem FindTenantInfoByExternalOrgId(Guid externalOrgId)
        {
            TenantPartitionCacheItem tenantPartitionCacheItem = null;

            if (externalOrgId == TemplateTenantConfiguration.TemplateTenantExternalDirectoryOrganizationIdGuid)
            {
                ExchangeConfigurationUnit localTemplateTenant = TemplateTenantConfiguration.GetLocalTemplateTenant();
                if (localTemplateTenant != null)
                {
                    ExTraceGlobals.GLSTracer.TraceDebug <string>(0L, "FindTenantInfoByExternalOrgId() asked for Consumer Template tenant, returning {0}", localTemplateTenant.Id.Parent.DistinguishedName);
                    string name = localTemplateTenant.Id.Parent.Name;
                    tenantPartitionCacheItem = new TenantPartitionCacheItem(Guid.Empty, localTemplateTenant.OrganizationId.PartitionId.ForestFQDN, PartitionId.LocalForest.ForestFQDN, externalOrgId, name, false);
                }
                return(tenantPartitionCacheItem);
            }
            PartitionId partitionId;

            if (!ADSessionSettings.IsGlsDisabled)
            {
                if (ADAccountPartitionLocator.TryLookUpAccountForest(externalOrgId, null, null, out tenantPartitionCacheItem))
                {
                    return(tenantPartitionCacheItem);
                }
            }
            else if (ADAccountPartitionLocator.IsSingleForestTopology(out partitionId))
            {
                ExTraceGlobals.GLSTracer.TraceDebug <Guid>(0L, "GLS is disabled, performing the only partition lookup for {0}", externalOrgId);
                return(ADAccountPartitionLocator.SearchForTenantInfoByExternalOrgId(externalOrgId, partitionId));
            }
            if (GlsMServDirectorySession.ShouldScanAllForests)
            {
                ADAccountPartitionLocator.LoadPartitionCacheIfNecessary();
                PartitionId[] array = ADAccountPartitionLocator.allAccountPartitionIds;
                foreach (PartitionId partitionId2 in array)
                {
                    tenantPartitionCacheItem = ADAccountPartitionLocator.SearchForTenantInfoByExternalOrgId(externalOrgId, partitionId2);
                    if (tenantPartitionCacheItem != null)
                    {
                        ADAccountPartitionLocator.InsertCacheMaps(tenantPartitionCacheItem, null, null);
                        return(tenantPartitionCacheItem);
                    }
                }
            }
            return(null);
        }
示例#10
0
 public bool IsConsumer()
 {
     return((this.tenantName != null && TemplateTenantConfiguration.IsTemplateTenantName(this.tenantName)) || (this.externalDirectoryOrganizationId != null && this.GetExternalDirectoryOrganizationId() == TemplateTenantConfiguration.TemplateTenantExternalDirectoryOrganizationIdGuid));
 }
        internal static bool IsTemplateTenant(OrganizationId orgId)
        {
            if (orgId == null)
            {
                throw new ArgumentNullException("orgId");
            }
            ADObjectId organizationalUnit = orgId.OrganizationalUnit;

            return(organizationalUnit != null && organizationalUnit.DistinguishedName != null && TemplateTenantConfiguration.IsTemplateTenantName(organizationalUnit.Name));
        }
示例#12
0
 internal static bool IsConsumerOrganization(OrganizationId organizationId)
 {
     return(TemplateTenantConfiguration.IsTemplateTenant(organizationId));
 }