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;
     }
 }
Esempio n. 2
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);
        }