Beispiel #1
0
 internal static ADObjectId TryGetServerIdByFqdn(IFindMiniServer findMiniServer, string fqdn)
 {
     if (!string.IsNullOrEmpty(fqdn))
     {
         IADServer iadserver = findMiniServer.FindMiniServerByFqdn(fqdn);
         if (iadserver != null)
         {
             return(iadserver.Id);
         }
     }
     return(null);
 }
Beispiel #2
0
        internal static void GetServerInformationForDatabaseInternal(IADDatabase database, DatabaseLocationInfo minimalLocationInfo, IFindMiniServer findMiniServer)
        {
            Guid       guid = database.Guid;
            string     lastMountedServerFqdn = minimalLocationInfo.LastMountedServerFqdn;
            IADServer  iadserver             = null;
            ADObjectId adobjectId            = null;
            string     serverFqdn            = minimalLocationInfo.ServerFqdn;

            if (serverFqdn != null)
            {
                iadserver = findMiniServer.FindMiniServerByFqdn(serverFqdn);
            }
            else
            {
                ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <string>(0L, "GetServerInformationForDatabaseInternal({0}) is falling back to database.Server from AD, which may be stale.", database.Name);
                iadserver = findMiniServer.ReadMiniServerByObjectId(database.Server);
            }
            if (iadserver == null)
            {
                throw new UnableToFindServerForDatabaseException(database.Name, guid.ToString());
            }
            ADObjectId serverSiteFromMiniServer = ActiveManagerUtil.GetServerSiteFromMiniServer(iadserver);
            string     fqdn = iadserver.Fqdn;

            if (iadserver.IsExchange2007OrLater && (serverSiteFromMiniServer == null || string.IsNullOrEmpty(fqdn) || (iadserver.IsExchange2007OrLater && !iadserver.IsMailboxServer)))
            {
                throw new UnableToFindServerForDatabaseException(database.Name, guid.ToString());
            }
            if (string.Equals(lastMountedServerFqdn, serverFqdn, StringComparison.OrdinalIgnoreCase))
            {
                adobjectId = iadserver.Id;
            }
            else
            {
                adobjectId = ActiveManagerImplementation.TryGetServerIdByFqdn(findMiniServer, lastMountedServerFqdn);
            }
            if (adobjectId == null)
            {
                ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <ADObjectId>(0L, "lastMountedServer was null. Setting to the current server ({0}).", iadserver.Id);
                adobjectId = iadserver.Id;
            }
            DatabaseLocationInfoResult requestResult = DatabaseLocationInfoResult.Success;
            IADServer iadserver2 = null;

            if (iadserver.Id.Equals(adobjectId))
            {
                iadserver2 = iadserver;
            }
            else
            {
                try
                {
                    iadserver2 = findMiniServer.ReadMiniServerByObjectId(adobjectId);
                }
                catch (ADTransientException arg)
                {
                    ActiveManagerImplementation.Tracer.TraceDebug <ADTransientException>(0L, "ReadMiniServer() threw an ADTransientException: {0}", arg);
                }
            }
            IADToplogyConfigurationSession adSession = findMiniServer.AdSession;
            IADSite iadsite = ActiveManagerImplementation.RetrieveLocalSite(adSession);

            if (iadsite == null)
            {
                ExTraceGlobals.ActiveManagerClientTracer.TraceDebug(0L, "GetServerForDatabase detected an Unknown state! adSession.GetLocalSite() is null.");
                requestResult = DatabaseLocationInfoResult.Unknown;
            }
            else if (iadserver2 == null)
            {
                ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <ADObjectId>(0L, "GetServerForDatabase detected an Unknown state! lastMountedServerId ({0}) could not be resolved.", adobjectId);
                requestResult = DatabaseLocationInfoResult.Unknown;
            }
            else if (!iadserver.Id.Equals(adobjectId))
            {
                ADObjectId serverSiteFromMiniServer2 = ActiveManagerUtil.GetServerSiteFromMiniServer(iadserver2);
                if (serverSiteFromMiniServer == serverSiteFromMiniServer2 || (serverSiteFromMiniServer != null && serverSiteFromMiniServer.Equals(serverSiteFromMiniServer2)))
                {
                    ExTraceGlobals.ActiveManagerClientTracer.TraceDebug(0L, "GetServerForDatabase detected InTransitSameSite! masterServer (name={0},site={1}), lastMountedServer (name={2},site={3}.", new object[]
                    {
                        iadserver.Id,
                        serverSiteFromMiniServer,
                        adobjectId,
                        serverSiteFromMiniServer2
                    });
                    requestResult = DatabaseLocationInfoResult.InTransitSameSite;
                }
                else
                {
                    ExTraceGlobals.ActiveManagerClientTracer.TraceDebug(0L, "GetServerForDatabase detected InTransitCrossSite! masterServer (name={0},site={1}), lastMountedServer (name={2},site={3}.", new object[]
                    {
                        iadserver.Id,
                        serverSiteFromMiniServer,
                        adobjectId,
                        serverSiteFromMiniServer2
                    });
                    requestResult = DatabaseLocationInfoResult.InTransitCrossSite;
                }
            }
            else if (!iadsite.Id.Equals(serverSiteFromMiniServer))
            {
                ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <ADObjectId, ADObjectId>(0L, "GetServerForDatabase detected a SiteViolation! GetLocalSite().Id != serverSiteId ({0} != {1}).", iadsite.Id, serverSiteFromMiniServer);
                requestResult = DatabaseLocationInfoResult.SiteViolation;
            }
            string        exchangeLegacyDN    = iadserver.ExchangeLegacyDN;
            ServerVersion adminDisplayVersion = iadserver.AdminDisplayVersion;
            Guid          objectGuid          = iadserver.Id.ObjectGuid;
            string        exchangeLegacyDN2   = iadserver2.ExchangeLegacyDN;

            iadserver2 = null;
            ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <Guid>(0L, "GetServerInformationForDatabaseInternal: Updating the location information for {0} in place.", guid);
            ADObjectId mailboxPublicFolderDatabase = database.MailboxPublicFolderDatabase;

            minimalLocationInfo.UpdateInPlace(fqdn, exchangeLegacyDN, minimalLocationInfo.LastMountedServerFqdn, exchangeLegacyDN2, database.ExchangeLegacyDN, database.RpcClientAccessServerLegacyDN, database.Name, database.IsPublicFolderDatabase, database.Recovery, (mailboxPublicFolderDatabase != null) ? mailboxPublicFolderDatabase.ObjectGuid : Guid.Empty, minimalLocationInfo.MountedTime, new Guid?(objectGuid), serverSiteFromMiniServer, adminDisplayVersion, iadserver.MailboxRelease, requestResult, minimalLocationInfo.IsDatabaseHighlyAvailable);
        }