private static IEnumerable <ADSessionSettings> CreateSessionSettingsCollection(bool includeAccountForestRootOrg, bool includeResourceForest, bool includeSecondaryPartitions = false)
        {
            List <ADSessionSettings> list = new List <ADSessionSettings>();
            bool flag = false;

            if (VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled)
            {
                PartitionId[] allAccountPartitionIds = ADAccountPartitionLocator.GetAllAccountPartitionIds(includeSecondaryPartitions);
                list.AddRange(allAccountPartitionIds.Select(new Func <PartitionId, ADSessionSettings>(ADSessionSettings.FromAllTenantsPartitionId)));
                if (includeAccountForestRootOrg)
                {
                    list.AddRange(allAccountPartitionIds.Select(new Func <PartitionId, ADSessionSettings>(ADSessionSettings.FromAccountPartitionRootOrgScopeSet)));
                    flag = allAccountPartitionIds.Contains(PartitionId.LocalForest);
                    if (ExEnvironment.IsTest && !flag)
                    {
                        flag = allAccountPartitionIds.Any((PartitionId id) => id.ForestFQDN.Contains(PartitionId.LocalForest.ForestFQDN));
                    }
                }
            }
            if (includeResourceForest && !flag)
            {
                list.Add(ADSessionSettings.FromRootOrgScopeSet());
            }
            return(list);
        }
 public static void RunOperationOnAllAccountPartitions(bool readOnly, PartitionDataAggregator.OperationDelegate operation)
 {
     foreach (PartitionId partitionId in ADAccountPartitionLocator.GetAllAccountPartitionIds())
     {
         ADSessionSettings sessionSettings  = ADSessionSettings.FromAllTenantsPartitionId(partitionId);
         IRecipientSession recipientSession = DirectorySessionFactory.Default.CreateTenantRecipientSession(readOnly, ConsistencyMode.IgnoreInvalid, sessionSettings, 185, "RunOperationOnAllAccountPartitions", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\PartitionDataAggregator.cs");
         operation(recipientSession);
     }
 }
        public static ADUser[] FindAllArbitrationMailboxes(string legDN)
        {
            List <ADUser> list = new List <ADUser>();

            foreach (PartitionId partitionId in ADAccountPartitionLocator.GetAllAccountPartitionIds())
            {
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 367, "FindAllArbitrationMailboxes", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\PartitionDataAggregator.cs");
                ADUser[]          collection = tenantOrRootOrgRecipientSession.FindPaged <ADUser>(RecipientFilterHelper.DiscoveryMailboxFilterForAuditLog(legDN), null, true, null, 0).ToArray <ADUser>();
                list.AddRange(collection);
            }
            return(list.ToArray());
        }
        public static ADRawEntry FindUserBySid(SecurityIdentifier sId, IList <PropertyDefinition> properties, ref IRecipientSession recipientSession)
        {
            ADRawEntry adrawEntry = null;

            foreach (PartitionId partitionId in ADAccountPartitionLocator.GetAllAccountPartitionIds())
            {
                ITenantRecipientSession tenantRecipientSession = DirectorySessionFactory.Default.CreateTenantRecipientSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 286, "FindUserBySid", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\PartitionDataAggregator.cs");
                adrawEntry = tenantRecipientSession.FindUserBySid(sId, properties);
                if (adrawEntry != null)
                {
                    recipientSession = tenantRecipientSession;
                    break;
                }
            }
            return(adrawEntry);
        }
        public static IEnumerable <ADUser> GetUMEnabledUsersInDatabase(MailboxDatabase database)
        {
            QueryFilter filter = UMMailbox.GetUMEnabledUserQueryFilter(database);

            foreach (PartitionId partitionId in ADAccountPartitionLocator.GetAllAccountPartitionIds(true))
            {
                ADSessionSettings           settings        = ADSessionSettings.FromAllTenantsPartitionId(partitionId);
                ITenantRecipientSession     session         = DirectorySessionFactory.Default.CreateTenantRecipientSession(null, null, LcidMapper.DefaultLcid, true, ConsistencyMode.IgnoreInvalid, null, settings, 199, "GetUMEnabledUsersInDatabase", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\PartitionDataAggregator.cs");
                ADPagedReader <ADRecipient> recipientReader = session.FindPaged(null, QueryScope.SubTree, filter, null, 0);
                foreach (ADRecipient recipient in recipientReader)
                {
                    ADUser user = recipient as ADUser;
                    if (user != null)
                    {
                        yield return(user);
                    }
                }
            }
            yield break;
        }
        public static MiniRecipient GetMiniRecipientFromUserId(SecurityIdentifier sid, IEnumerable <PropertyDefinition> properties, ConsistencyMode consistencyMode)
        {
            MiniRecipient miniRecipient = null;

            foreach (PartitionId partitionId in ADAccountPartitionLocator.GetAllAccountPartitionIds())
            {
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, consistencyMode, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 249, "GetMiniRecipientFromUserId", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\PartitionDataAggregator.cs");
                try
                {
                    miniRecipient = tenantOrRootOrgRecipientSession.FindMiniRecipientBySid <MiniRecipient>(sid, properties);
                }
                catch (NonUniqueRecipientException)
                {
                }
                if (miniRecipient != null)
                {
                    break;
                }
            }
            return(miniRecipient);
        }
        private static IEnumerable <T> FindPaged <T>(QueryFilter filter, bool includeRetiredTenants = false, SortBy sortBy = null) where T : ADConfigurationObject, new()
        {
            PartitionId[] allAccountPartitionIds = ADAccountPartitionLocator.GetAllAccountPartitionIds();
            int           i = 0;

            while (i < allAccountPartitionIds.Length)
            {
                PartitionId       partitionId = allAccountPartitionIds[i];
                ADPagedReader <T> tenantReader;
                try
                {
                    ADSessionSettings adsessionSettings = ADSessionSettings.FromAllTenantsPartitionId(partitionId);
                    if (includeRetiredTenants)
                    {
                        adsessionSettings.TenantConsistencyMode = TenantConsistencyMode.IncludeRetiredTenants;
                    }
                    ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, adsessionSettings, 641, "FindPaged", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\PartitionDataAggregator.cs");
                    tenantReader = tenantConfigurationSession.FindPaged <T>(null, QueryScope.SubTree, filter, sortBy, 0);
                }
                catch (OrgContainerNotFoundException)
                {
                    if (Globals.IsDatacenter)
                    {
                        goto IL_10B;
                    }
                    throw;
                }
                goto IL_AF;
IL_10B:
                i++;
                continue;
IL_AF:
                foreach (T request in tenantReader)
                {
                    yield return(request);
                }
                goto IL_10B;
            }
            yield break;
        }
 // Token: 0x06000321 RID: 801 RVA: 0x00010F2A File Offset: 0x0000F12A
 internal static PartitionId[] GetAllAccountPartitionIds()
 {
     return(ADAccountPartitionLocator.GetAllAccountPartitionIds(false));
 }