예제 #1
0
        // Token: 0x06001208 RID: 4616 RVA: 0x00037FB4 File Offset: 0x000361B4
        internal static MailboxDatabaseWithLocationInfo FindDatabaseAndLocationForEnterpriseSiteMailbox(string domainController, LogMessageDelegate logger, ScopeSet scopeSet)
        {
            PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbEnterSiteMailboxEnterprise, logger);
            ITopologyConfigurationSession configSession = PhysicalResourceLoadBalancing.CreateGlobalConfigSession(domainController);
            List <MailboxDatabase>        databasesForProvisioningCached = PhysicalResourceLoadBalancing.GetDatabasesForProvisioningCached(configSession, false, logger);

            if (databasesForProvisioningCached.Count == 0)
            {
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoAvailableDatabase, logger);
                return(null);
            }
            List <MailboxDatabase> list = new List <MailboxDatabase>();

            foreach (MailboxDatabase mailboxDatabase in databasesForProvisioningCached)
            {
                if (mailboxDatabase.AdminDisplayVersion == null)
                {
                    mailboxDatabase.AdminDisplayVersion = Server.GetServerVersion(mailboxDatabase.ServerName);
                }
                if (mailboxDatabase.AdminDisplayVersion.Major >= PhysicalResourceLoadBalancing.MajorVersionE15)
                {
                    list.Add(mailboxDatabase);
                }
            }
            if (list.Count == 0)
            {
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoAvailableE15Database(databasesForProvisioningCached.Count), logger);
                return(null);
            }
            ActiveManager cachingActiveManagerInstance = ActiveManager.GetCachingActiveManagerInstance();
            Random        random = new Random();

            while (list.Count != 0)
            {
                int             index            = random.Next(list.Count);
                MailboxDatabase mailboxDatabase2 = list[index];
                list.RemoveAt(index);
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbGetServerForActiveDatabaseCopy(mailboxDatabase2.Name), logger);
                DatabaseLocationInfo serverForActiveDatabaseCopy = PhysicalResourceLoadBalancing.GetServerForActiveDatabaseCopy(mailboxDatabase2, cachingActiveManagerInstance, logger);
                if (serverForActiveDatabaseCopy != null)
                {
                    MailboxDatabaseWithLocationInfo mailboxDatabaseWithLocationInfo = new MailboxDatabaseWithLocationInfo(mailboxDatabase2, serverForActiveDatabaseCopy);
                    if (mailboxDatabase2.MasterType == MasterType.DatabaseAvailabilityGroup)
                    {
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbRemoteSiteDatabaseReturned(mailboxDatabaseWithLocationInfo.MailboxDatabase.Name, mailboxDatabaseWithLocationInfo.DatabaseLocationInfo.ServerFqdn), logger);
                        return(mailboxDatabaseWithLocationInfo);
                    }
                    mailboxDatabaseWithLocationInfo = PhysicalResourceLoadBalancing.VerifyStatusAndSelectDB(new List <MailboxDatabaseWithLocationInfo>
                    {
                        mailboxDatabaseWithLocationInfo
                    }, domainController, logger, scopeSet);
                    if (mailboxDatabaseWithLocationInfo != null)
                    {
                        return(mailboxDatabaseWithLocationInfo);
                    }
                }
            }
            return(null);
        }
예제 #2
0
        // Token: 0x06001209 RID: 4617 RVA: 0x0003817C File Offset: 0x0003637C
        internal static Server FindMailboxServer(string domainController, OfflineAddressBook currentOABSettings, LogMessageDelegate logger)
        {
            ITopologyConfigurationSession topologyConfigurationSession = PhysicalResourceLoadBalancing.CreateGlobalConfigSession(domainController);
            QueryFilter filter = new AndFilter(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, ServerSchema.VersionNumber, Server.E14MinVersion),
                new BitMaskAndFilter(ServerSchema.CurrentServerRole, 2UL),
                new ComparisonFilter(ComparisonOperator.Equal, ActiveDirectoryServerSchema.IsExcludedFromProvisioning, false)
            });

            PhysicalResourceLoadBalancing.LogVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(topologyConfigurationSession, typeof(Server), filter, null, true), logger);
            ADPagedReader <Server> adpagedReader = topologyConfigurationSession.FindPaged <Server>(null, QueryScope.SubTree, filter, null, 0);
            List <Server>          list          = new List <Server>();

            foreach (Server server in adpagedReader)
            {
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbFoundMailboxServer(server.Identity.ToString()), logger);
                list.Add(server);
            }
            if (currentOABSettings.Server != null)
            {
                Server currentOABServer = topologyConfigurationSession.Read <Server>(currentOABSettings.Server);
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbOABIsCurrentlyOnServer((currentOABServer == null) ? Strings.VerboseLbDeletedServer : currentOABServer.Identity.ToString()), logger);
                if (currentOABServer != null && list.Find((Server s) => ADObjectId.Equals(s.Id, currentOABServer.Id)) != null)
                {
                    if (list.Count == 1)
                    {
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbOnlyOneEligibleServer(currentOABServer.Identity.ToString()), logger);
                        return(currentOABServer);
                    }
                    list.RemoveAll((Server s) => ADObjectId.Equals(s.Id, currentOABServer.Id));
                }
            }
            if (list.Count == 0)
            {
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoEligibleServers, logger);
                return(null);
            }
            if (list.Count == 1)
            {
                return(list[0]);
            }
            Random random  = new Random();
            Server server2 = list[random.Next(0, list.Count)];

            PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbReturningServer(server2.Identity.ToString()), logger);
            return(server2);
        }
예제 #3
0
        // Token: 0x0600120A RID: 4618 RVA: 0x00038380 File Offset: 0x00036580
        internal static IEnumerable FindVirtualDirectories(string domainController, LogMessageDelegate logger)
        {
            ITopologyConfigurationSession topologyConfigurationSession = PhysicalResourceLoadBalancing.CreateGlobalConfigSession(domainController);

            PhysicalResourceLoadBalancing.LogVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(topologyConfigurationSession, typeof(ADOabVirtualDirectory), null, null, true), logger);
            ADPagedReader <ADOabVirtualDirectory>           adpagedReader = topologyConfigurationSession.FindPaged <ADOabVirtualDirectory>(null, QueryScope.SubTree, null, null, 0);
            List <ComparableEntry <ADOabVirtualDirectory> > list          = new List <ComparableEntry <ADOabVirtualDirectory> >();

            foreach (ADOabVirtualDirectory adoabVirtualDirectory in adpagedReader)
            {
                ServerVersion serverVersion = null;
                if (adoabVirtualDirectory.Server != null)
                {
                    serverVersion = Server.GetServerVersion(adoabVirtualDirectory.Server.Name);
                }
                if (!(serverVersion == null) && ServerVersion.Compare(serverVersion, PhysicalResourceLoadBalancing.E15MinVersion) >= 0)
                {
                    list.Add(new ComparableEntry <ADOabVirtualDirectory>(adoabVirtualDirectory)
                    {
                        Count = adoabVirtualDirectory.OfflineAddressBooks.Count
                    });
                    PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbFoundOabVDir(adoabVirtualDirectory.Id.ToDNString(), adoabVirtualDirectory.OfflineAddressBooks.Count), logger);
                }
            }
            list.Sort();
            int num = PhysicalResourceLoadBalancing.MaxNumOfVdirs;

            if (num > list.Count)
            {
                num = list.Count;
            }
            if (num == 0)
            {
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoOabVDirReturned, logger);
            }
            List <ADObjectId> list2 = new List <ADObjectId>(num);

            for (int i = 0; i < num; i++)
            {
                list2.Add(list[i].Entry.Id);
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbOabVDirSelected(list[i].Entry.Id.ToDNString()), logger);
            }
            return(list2);
        }
예제 #4
0
        // Token: 0x06001206 RID: 4614 RVA: 0x00037DC8 File Offset: 0x00035FC8
        internal static MailboxDatabaseWithLocationInfo FindDatabaseAndLocation(string domainController, LogMessageDelegate logger, ScopeSet scopeSet, bool isInitialProvisioning, bool localSiteDatabasesOnly, int?qualifiedMinServerVersion, IMailboxProvisioningConstraint mailboxProvisioningConstraint, IEnumerable <ADObjectId> excludedDatabaseIds, ref LoadBalancingReport loadBalancingReport)
        {
            ITopologyConfigurationSession configSession = PhysicalResourceLoadBalancing.CreateGlobalConfigSession(domainController);
            List <MailboxDatabase>        databasesForProvisioningCached = PhysicalResourceLoadBalancing.GetDatabasesForProvisioningCached(configSession, localSiteDatabasesOnly, logger);
            List <MailboxDatabase>        list;

            if (mailboxProvisioningConstraint != null || excludedDatabaseIds != null)
            {
                list = PhysicalResourceLoadBalancing.FilterEligibleDatabase(logger, databasesForProvisioningCached.GetRange(0, databasesForProvisioningCached.Count), mailboxProvisioningConstraint, excludedDatabaseIds);
            }
            else
            {
                list = databasesForProvisioningCached.GetRange(0, databasesForProvisioningCached.Count);
            }
            if (list.Count == 0)
            {
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoAvailableDatabase, logger);
                return(null);
            }
            LoadBalancingReport loadBalancingReport2 = loadBalancingReport ?? new LoadBalancingReport();

            loadBalancingReport2.enabledDatabasesWithLocalCopyCount = list.Count;
            ActiveManager cachingActiveManagerInstance = ActiveManager.GetCachingActiveManagerInstance();

            if (PhysicalResourceLoadBalancing.IsDatacenter)
            {
                return(PhysicalResourceLoadBalancing.FindDatabaseAndLocation(list, cachingActiveManagerInstance, isInitialProvisioning, localSiteDatabasesOnly, logger, ref loadBalancingReport2));
            }
            List <MailboxDatabaseWithLocationInfo> list2 = new List <MailboxDatabaseWithLocationInfo>(list.Count);

            foreach (MailboxDatabase mailboxDatabase in list)
            {
                DatabaseLocationInfo serverForActiveDatabaseCopy = PhysicalResourceLoadBalancing.GetServerForActiveDatabaseCopy(mailboxDatabase, cachingActiveManagerInstance, logger);
                if (serverForActiveDatabaseCopy != null && PhysicalResourceLoadBalancing.IsDatabaseInLocalSite(serverForActiveDatabaseCopy, logger) && (qualifiedMinServerVersion == null || serverForActiveDatabaseCopy.ServerVersion >= qualifiedMinServerVersion.Value))
                {
                    list2.Add(new MailboxDatabaseWithLocationInfo(mailboxDatabase, serverForActiveDatabaseCopy));
                }
            }
            return(PhysicalResourceLoadBalancing.VerifyStatusAndSelectDB(list2, domainController, logger, scopeSet));
        }
예제 #5
0
        // Token: 0x0600120B RID: 4619 RVA: 0x000384FC File Offset: 0x000366FC
        private static MailboxDatabaseWithLocationInfo VerifyStatusAndSelectDB(List <MailboxDatabaseWithLocationInfo> databases, string domainController, LogMessageDelegate logger, ScopeSet scopeSet)
        {
            Guid[]      array  = new Guid[1];
            MdbStatus[] array2 = new MdbStatus[1];
            Dictionary <string, ExRpcAdmin> dictionary  = new Dictionary <string, ExRpcAdmin>(100);
            Dictionary <string, string>     dictionary2 = new Dictionary <string, string>(100);
            ITopologyConfigurationSession   topologyConfigurationSession = PhysicalResourceLoadBalancing.CreateGlobalConfigSession(domainController);
            IConfigurationSession           configurationSession         = null;

            if (scopeSet != null && !PhysicalResourceLoadBalancing.IsDatacenter)
            {
                configurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromCustomScopeSet(scopeSet, topologyConfigurationSession.SessionSettings.RootOrgId, topologyConfigurationSession.SessionSettings.CurrentOrganizationId, topologyConfigurationSession.SessionSettings.ExecutingUserOrganizationId, true), 801, "VerifyStatusAndSelectDB", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\Provisioning\\LoadBalancing\\PhysicalResourceLoadBalancing.cs");
            }
            try
            {
                Random random = new Random();
                for (int i = databases.Count - 1; i >= 0; i--)
                {
                    if (i != 0)
                    {
                        int index = random.Next(i + 1);
                        MailboxDatabaseWithLocationInfo value = databases[index];
                        databases[index] = databases[i];
                        databases[i]     = value;
                    }
                    MailboxDatabase mailboxDatabase = databases[i].MailboxDatabase;
                    string          text            = string.Empty;
                    try
                    {
                        if (configurationSession != null)
                        {
                            PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbCheckingDatabaseIsAllowedOnScope(mailboxDatabase.Id.ToDNString()), logger);
                            ADScopeException ex;
                            if (!configurationSession.TryVerifyIsWithinScopes(mailboxDatabase, false, out ex))
                            {
                                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseNotInUserScope(mailboxDatabase.Id.ToDNString(), ex.ToString()), logger);
                                goto IL_2C6;
                            }
                        }
                        DatabaseLocationInfo databaseLocationInfo = databases[i].DatabaseLocationInfo;
                        text = databaseLocationInfo.ServerFqdn;
                        ADObjectId serverSite = databaseLocationInfo.ServerSite;
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseAndServerTry(mailboxDatabase.Id.ToDNString(), text ?? "null"), logger);
                        if (!string.IsNullOrEmpty(text) && !dictionary2.ContainsKey(text))
                        {
                            ExRpcAdmin exRpcAdmin;
                            if (dictionary.ContainsKey(text))
                            {
                                exRpcAdmin = dictionary[text];
                                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbExRpcAdminExists, logger);
                            }
                            else
                            {
                                exRpcAdmin = ExRpcAdmin.Create("Client=Management", text, null, null, null);
                                dictionary.Add(text, exRpcAdmin);
                                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbCreateNewExRpcAdmin, logger);
                            }
                            array[0] = mailboxDatabase.Id.ObjectGuid;
                            array2   = exRpcAdmin.ListMdbStatus(array);
                            PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbTryRetrieveDatabaseStatus, logger);
                            if ((array2[0].Status & MdbStatusFlags.Online) != MdbStatusFlags.Offline)
                            {
                                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseFound, logger);
                                return(new MailboxDatabaseWithLocationInfo(mailboxDatabase, databaseLocationInfo));
                            }
                            PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseIsNotOnline((int)array2[0].Status), logger);
                        }
                        else
                        {
                            PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbServerDownSoMarkDatabaseDown, logger);
                        }
                    }
                    catch (DatabaseNotFoundException ex2)
                    {
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseNotFoundException(ex2.Message), logger);
                    }
                    catch (ObjectNotFoundException ex3)
                    {
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoServerForDatabaseException(ex3.Message), logger);
                    }
                    catch (MapiExceptionNetworkError mapiExceptionNetworkError)
                    {
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNetworkError(mapiExceptionNetworkError.Message), logger);
                        dictionary2.Add(text, text);
                    }
                    catch (MapiPermanentException ex4)
                    {
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbPermanentException(ex4.Message), logger);
                        dictionary2.Add(text, text);
                    }
                    catch (MapiRetryableException ex5)
                    {
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbRetryableException(ex5.Message), logger);
                    }
                    IL_2C6 :;
                }
            }
            finally
            {
                foreach (string text2 in dictionary.Keys)
                {
                    PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDisposeExRpcAdmin(text2), logger);
                    dictionary[text2].Dispose();
                }
            }
            PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoAvailableDatabase, logger);
            return(null);
        }
예제 #6
0
        // Token: 0x06001201 RID: 4609 RVA: 0x00037AD4 File Offset: 0x00035CD4
        internal static List <MailboxDatabase> GetAllCachedDatabasesForProvisioning(string domainController, LogMessageDelegate logger)
        {
            ITopologyConfigurationSession configSession = PhysicalResourceLoadBalancing.CreateGlobalConfigSession(domainController);

            return(PhysicalResourceLoadBalancing.GetDatabasesForProvisioningCached(configSession, false, logger));
        }