Exemplo n.º 1
0
        // Token: 0x06001212 RID: 4626 RVA: 0x00038AD8 File Offset: 0x00036CD8
        private static List <MailboxDatabase> GetDatabasesOnMailboxServers(ITopologyConfigurationSession configSession, Server[] mailboxServers, LogMessageDelegate logger)
        {
            Dictionary <string, MailboxDatabase> allEnabledDatabases = PhysicalResourceLoadBalancing.GetAllEnabledDatabases(configSession, logger);
            List <MailboxDatabase> list = new List <MailboxDatabase>();

            if (allEnabledDatabases.Count > 0)
            {
                HashSet <string> hashSet = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                foreach (Server server in mailboxServers)
                {
                    hashSet.Add(server.Name);
                }
                QueryFilter filter = new OrFilter(new QueryFilter[]
                {
                    new NotFilter(new ExistsFilter(DatabaseCopySchema.ParentObjectClass)),
                    new TextFilter(DatabaseCopySchema.ParentObjectClass, MailboxDatabase.MostDerivedClass, MatchOptions.FullString, MatchFlags.IgnoreCase)
                });
                ADObjectId rootId = ProvisioningCache.Instance.TryAddAndGetGlobalData <ADObjectId>(CannedProvisioningCacheKeys.DatabaseContainerId, new ProvisioningCache.CacheObjectGetterDelegate(configSession.GetDatabasesContainerId));
                PhysicalResourceLoadBalancing.LogVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(configSession, typeof(DatabaseCopy), filter, rootId, false), logger);
                ADPagedReader <DatabaseCopy> adpagedReader = configSession.FindPaged <DatabaseCopy>(rootId, QueryScope.SubTree, filter, null, 0);
                int num = 0;
                foreach (DatabaseCopy databaseCopy in adpagedReader)
                {
                    MailboxDatabase mailboxDatabase;
                    if (databaseCopy.IsValid && allEnabledDatabases.TryGetValue(databaseCopy.DatabaseName, out mailboxDatabase) && !string.IsNullOrEmpty(mailboxDatabase.ServerName) && hashSet.Contains(mailboxDatabase.ServerName))
                    {
                        allEnabledDatabases.Remove(databaseCopy.DatabaseName);
                        list.Add(mailboxDatabase);
                    }
                    num++;
                }
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbGeneralTrace(string.Format("Retrieved '{0}' mailbox database copies. '{1}' databases have copies on selected mailbox servers.", num, list.Count)), logger);
            }
            if (list.Count <= 0)
            {
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoDatabaseFoundInAD, logger);
            }
            return(list);
        }