Пример #1
0
        public static OwaService GetOwaService(ExchangePrincipal principal)
        {
            OwaService owaService = null;

            try
            {
                ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MultiMailboxSearch\\LinkUtils.cs", "GetOwaService", 197);
                owaService = (from x in currentServiceTopology.FindAll <OwaService>(principal, ClientAccessType.External, "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MultiMailboxSearch\\LinkUtils.cs", "GetOwaService", 200)
                              where x.IsFrontEnd
                              select x).FirstOrDefault <OwaService>();
                if (owaService == null)
                {
                    owaService = (from x in currentServiceTopology.FindAll <OwaService>(principal, ClientAccessType.Internal, "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MultiMailboxSearch\\LinkUtils.cs", "GetOwaService", 207)
                                  where x.IsFrontEnd
                                  select x).FirstOrDefault <OwaService>();
                }
                if (owaService == null)
                {
                    Factory.Current.EventLog.LogEvent(InfoWorkerEventLogConstants.Tuple_DiscoveryFailedToGetOWAService, null, new object[]
                    {
                        principal.MailboxInfo.Location.ServerFqdn
                    });
                }
            }
            catch (ReadTopologyTimeoutException ex)
            {
                Factory.Current.EventLog.LogEvent(InfoWorkerEventLogConstants.Tuple_DiscoveryFailedToGetOWAServiceWithException, null, new object[]
                {
                    principal.MailboxInfo.Location.ServerFqdn,
                    ex.ToString()
                });
            }
            return(owaService);
        }
 // Token: 0x06000254 RID: 596 RVA: 0x0000BC90 File Offset: 0x00009E90
 private bool IsLocalSiteE15MailboxServer(BackEndServer server, string resourceForest)
 {
     if (!server.IsE15OrHigher)
     {
         return(false);
     }
     if ((!Utilities.IsPartnerHostedOnly && !CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).NoCrossForestServerLocate.Enabled) || string.IsNullOrEmpty(resourceForest) || string.Equals(HttpProxyGlobals.LocalMachineForest.Member, resourceForest, StringComparison.OrdinalIgnoreCase))
     {
         ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\Cache\\LocalSiteMailboxServerCache.cs", "IsLocalSiteE15MailboxServer", 238);
         Site            site = null;
         try
         {
             site = currentServiceTopology.GetSite(server.Fqdn, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\Cache\\LocalSiteMailboxServerCache.cs", "IsLocalSiteE15MailboxServer", 243);
         }
         catch (ServerNotFoundException)
         {
             return(false);
         }
         catch (ServerNotInSiteException)
         {
             return(false);
         }
         if (HttpProxyGlobals.LocalSite.Member.Equals(site))
         {
             return(true);
         }
         return(false);
     }
     return(false);
 }
Пример #3
0
        public static int?LookupVersion(string server)
        {
            int versionNumber;

            if (VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled && VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Cafe.ServersCache.Enabled)
            {
                try
                {
                    bool       flag;
                    MiniServer serverByFQDN = ServersCache.GetServerByFQDN(server, out flag);
                    versionNumber = serverByFQDN.VersionNumber;
                    goto IL_90;
                }
                catch (LocalServerNotFoundException)
                {
                    return(null);
                }
            }
            ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\Common\\Misc\\ServerLookup.cs", "LookupVersion", 45);

            if (!currentServiceTopology.TryGetServerVersion(server, out versionNumber, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\Common\\Misc\\ServerLookup.cs", "LookupVersion", 47))
            {
                return(null);
            }
IL_90:
            return(new int?(versionNumber));
        }
 protected override void RedirectIfNeeded(BackEndServer mailboxServer)
 {
     if (mailboxServer == null)
     {
         throw new ArgumentNullException("mailboxServer");
     }
     if (!Utilities.IsPartnerHostedOnly && !VariantConfiguration.InvariantNoFlightingSnapshot.Cafe.NoCrossSiteRedirect.Enabled)
     {
         ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 537);
         Site            targetSite             = currentServiceTopology.GetSite(mailboxServer.Fqdn, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 538);
         ADSite          localSite = LocalSiteCache.LocalSite;
         if (!localSite.DistinguishedName.Equals(targetSite.DistinguishedName) && (!this.IsLocalRequest(LocalServerCache.LocalServerFqdn) || !this.IsLAMUserAgent(base.ClientRequest.UserAgent)))
         {
             HttpService targetService = currentServiceTopology.FindAny <ServiceType>(ClientAccessType.Internal, (ServiceType internalService) => internalService != null && internalService.IsFrontEnd && internalService.Site.DistinguishedName.Equals(targetSite.DistinguishedName), "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 550);
             if (!this.ShouldExecuteSSORedirect(targetService))
             {
                 HttpService httpService = currentServiceTopology.FindAny <ServiceType>(ClientAccessType.External, (ServiceType externalService) => externalService != null && externalService.IsFrontEnd && externalService.Site.DistinguishedName.Equals(targetSite.DistinguishedName), "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 561);
                 if (httpService != null)
                 {
                     Uri url = httpService.Url;
                     if (Uri.Compare(url, base.ClientRequest.Url, UriComponents.Host, UriFormat.UriEscaped, StringComparison.OrdinalIgnoreCase) != 0)
                     {
                         UriBuilder uriBuilder = new UriBuilder(base.ClientRequest.Url);
                         uriBuilder.Host = url.Host;
                         ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "[OwaEcpProxyRequestHandler::RedirectIfNeeded]: Stop processing and redirect to {0}.", uriBuilder.Uri.AbsoluteUri);
                         throw new ServerSideTransferException(uriBuilder.Uri.AbsoluteUri, LegacyRedirectTypeOptions.Silent);
                     }
                 }
             }
         }
     }
 }
Пример #5
0
 private bool IsLocalSiteE15MailboxServer(BackEndServer server, string resourceForest)
 {
     if (!server.IsE15OrHigher)
     {
         return(false);
     }
     if ((!Utilities.IsPartnerHostedOnly && !VariantConfiguration.InvariantNoFlightingSnapshot.Cafe.NoCrossForestServerLocate.Enabled) || string.IsNullOrEmpty(resourceForest) || string.Equals(HttpProxyGlobals.LocalMachineForest.Member, resourceForest, StringComparison.OrdinalIgnoreCase))
     {
         ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\Cache\\LocalSiteMailboxServerCache.cs", "IsLocalSiteE15MailboxServer", 226);
         Site            other = null;
         try
         {
             other = currentServiceTopology.GetSite(server.Fqdn, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\Cache\\LocalSiteMailboxServerCache.cs", "IsLocalSiteE15MailboxServer", 231);
         }
         catch (ServerNotFoundException)
         {
             return(false);
         }
         catch (ServerNotInSiteException)
         {
             return(false);
         }
         if (HttpProxyGlobals.LocalSite.Member.Equals(other))
         {
             return(true);
         }
         return(false);
     }
     return(false);
 }
 // Token: 0x060005A4 RID: 1444 RVA: 0x0001F490 File Offset: 0x0001D690
 protected override void RedirectIfNeeded(BackEndServer mailboxServer)
 {
     if (mailboxServer == null)
     {
         throw new ArgumentNullException("mailboxServer");
     }
     if (!Utilities.IsPartnerHostedOnly && !CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).NoCrossSiteRedirect.Enabled)
     {
         ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 438);
         Site            targetSite             = currentServiceTopology.GetSite(mailboxServer.Fqdn, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 439);
         if (!LocalSiteCache.LocalSite.DistinguishedName.Equals(targetSite.DistinguishedName) && (!this.IsLocalRequest(LocalServerCache.LocalServerFqdn) || !this.IsLAMUserAgent(base.ClientRequest.UserAgent)))
         {
             HttpService targetService = currentServiceTopology.FindAny <ServiceType>(0, (ServiceType internalService) => internalService != null && internalService.IsFrontEnd && internalService.Site.DistinguishedName.Equals(targetSite.DistinguishedName), "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 451);
             if (!this.ShouldExecuteSSORedirect(targetService))
             {
                 HttpService httpService = currentServiceTopology.FindAny <ServiceType>(1, (ServiceType externalService) => externalService != null && externalService.IsFrontEnd && externalService.Site.DistinguishedName.Equals(targetSite.DistinguishedName), "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 462);
                 if (httpService != null)
                 {
                     Uri url = httpService.Url;
                     if (Uri.Compare(url, base.ClientRequest.Url, UriComponents.Host, UriFormat.UriEscaped, StringComparison.OrdinalIgnoreCase) != 0)
                     {
                         UriBuilder uriBuilder = new UriBuilder(base.ClientRequest.Url);
                         uriBuilder.Host = url.Host;
                         if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                         {
                             ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "[OwaEcpProxyRequestHandler::RedirectIfNeeded]: Stop processing and redirect to {0}.", uriBuilder.Uri.AbsoluteUri);
                         }
                         throw new HttpException(302, this.GetCrossSiteRedirectUrl(targetSite.DistinguishedName, uriBuilder.Path, uriBuilder.Query));
                     }
                 }
             }
         }
     }
 }
Пример #7
0
        public static string DiscoverEwsUrl(IExchangePrincipal mailbox)
        {
            Uri uri;

            if (!EwsHelper.IsDatacenter)
            {
                EwsHelper.Tracer.TraceDebug(0L, "Not running in DC. Will use ServiceTopology to discover the url");
                ServerVersion mailboxVersion = new ServerVersion(mailbox.MailboxInfo.Location.ServerVersion);
                IList <WebServicesService> list;
                try
                {
                    ClientAccessType clientAccessType = EwsHelper.ClientAccessType;
                    EwsHelper.Tracer.TraceDebug <ClientAccessType>(0L, "Will try to discover the URL for EWS with the following client access type: {0}", clientAccessType);
                    ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Management\\EwsDriver\\EwsHelper.cs", "DiscoverEwsUrl", 119);
                    list = currentServiceTopology.FindAll <WebServicesService>(mailbox, clientAccessType, delegate(WebServicesService service)
                    {
                        ServerVersion serverVersion = new ServerVersion(service.ServerVersionNumber);
                        return(mailboxVersion.Major == serverVersion.Major && mailboxVersion.Minor <= serverVersion.Minor && !service.IsOutOfService);
                    }, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Management\\EwsDriver\\EwsHelper.cs", "DiscoverEwsUrl", 121);
                }
                catch (LocalizedException arg)
                {
                    EwsHelper.Tracer.TraceError <IExchangePrincipal, LocalizedException>(0L, "Unable to discover internal URL for EWS for mailbox {0} due exception {1}", mailbox, arg);
                    return(null);
                }
                if (list.Count == 0)
                {
                    EwsHelper.Tracer.TraceError <IExchangePrincipal>(0L, "Unable to find internal URL for EWS for mailbox {0}", mailbox);
                    return(null);
                }
                WebServicesService webServicesService;
                if ((webServicesService = list.FirstOrDefault((WebServicesService service) => string.Equals(service.ServerFullyQualifiedDomainName, mailbox.MailboxInfo.Location.ServerFqdn, StringComparison.OrdinalIgnoreCase) && service.Url != null)) == null && (webServicesService = list.FirstOrDefault(delegate(WebServicesService service)
                {
                    ServerVersion serverVersion = new ServerVersion(service.ServerVersionNumber);
                    return(service.Url != null && mailboxVersion.Major == serverVersion.Major && mailboxVersion.Minor == serverVersion.Minor);
                })) == null)
                {
                    webServicesService = list.FirstOrDefault((WebServicesService service) => service.Url != null);
                }
                WebServicesService webServicesService2 = webServicesService;
                uri = ((webServicesService2 == null) ? null : webServicesService2.Url);
                goto IL_1EA;
            }
            EwsHelper.Tracer.TraceDebug(0L, "Running in DC. Will use BackEndLocator to discover the url");
            if (EwsHelper.discoveryEwsInternalUrl == null)
            {
                EwsHelper.discoveryEwsInternalUrl = (Func <IMailboxInfo, Uri>)Delegate.CreateDelegate(typeof(Func <IMailboxInfo, Uri>), Type.GetType("Microsoft.Exchange.Data.ApplicationLogic.Cafe.BackEndLocator, Microsoft.Exchange.Data.ApplicationLogic").GetMethod("GetBackEndWebServicesUrl", BindingFlags.Static | BindingFlags.Public, null, new Type[]
                {
                    typeof(IMailboxInfo)
                }, null));
            }
            uri = EwsHelper.discoveryEwsInternalUrl(mailbox.MailboxInfo);
IL_1EA:
            if (!(uri == null))
            {
                return(uri.ToString());
            }
            return(null);
        }
Пример #8
0
        public ServerInfoAnchorMailbox(BackEndServer backendServer, IRequestContext requestContext) : base(AnchorSource.ServerInfo, backendServer.Fqdn, requestContext)
        {
            ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\AnchorMailbox\\ServerInfoAnchorMailbox.cs", ".ctor", 60);
            int             num;

            if (!currentServiceTopology.TryGetServerVersion(backendServer.Fqdn, out num, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\AnchorMailbox\\ServerInfoAnchorMailbox.cs", ".ctor", 62))
            {
                throw new ArgumentException("Invalid value");
            }
            this.BackEndServer = backendServer;
        }
        private static Uri FindRedirectOwaUrlCrossSite(Site targetSite, int expectedMajorVersion, AuthenticationMethod internalAutheticationMethod, AuthenticationMethod externalAuthenticationMethod, BackEndServer backEndServer, out bool isSameAuthMethod, out FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause failureCause)
        {
            failureCause     = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None;
            isSameAuthMethod = false;
            bool            isSameAuthExternalService = false;
            OwaService      clientExternalService     = null;
            ServiceTopology currentServiceTopology    = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 390);
            string          mailboxServerFQDN         = backEndServer.Fqdn;

            new List <OwaService>();
            currentServiceTopology.ForEach <OwaService>(delegate(OwaService owaService)
            {
                if (ServiceTopology.IsOnSite(owaService, targetSite, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 401) && owaService.ClientAccessType == ClientAccessType.External)
                {
                    int major = OwaServerVersion.CreateFromVersionNumber(owaService.ServerVersionNumber).Major;
                    if (major == expectedMajorVersion)
                    {
                        bool flag = false;
                        if (owaService.AuthenticationMethod == internalAutheticationMethod || ((internalAutheticationMethod & AuthenticationMethod.Fba) != AuthenticationMethod.None && (owaService.AuthenticationMethod & AuthenticationMethod.Fba) != AuthenticationMethod.None))
                        {
                            flag = true;
                            if (!isSameAuthExternalService)
                            {
                                clientExternalService     = null;
                                isSameAuthExternalService = true;
                            }
                        }
                        if (flag || !isSameAuthExternalService)
                        {
                            if (clientExternalService == null)
                            {
                                clientExternalService = owaService;
                                return;
                            }
                            if (ServiceTopology.CasMbxServicesFirst(owaService, clientExternalService, mailboxServerFQDN, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 432) < 0)
                            {
                                clientExternalService = owaService;
                            }
                        }
                    }
                }
            }, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 396);
            if (clientExternalService != null)
            {
                isSameAuthMethod = isSameAuthExternalService;
                return(clientExternalService.Url);
            }
            failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.NoCasFound;
            return(null);
        }
Пример #10
0
        public Uri GetCasServerUri(ADObjectId site, int minServerVersionRequested, out int serverVersion)
        {
            SortedDictionary <int, List <WebServicesService> > uriVersions = null;

            serverVersion = 0;
            try
            {
                ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MessageTracking\\ServerCache.cs", "GetCasServerUri", 673);
                currentServiceTopology.ForEach <WebServicesService>(delegate(WebServicesService service)
                {
                    if (service.ServerVersionNumber >= minServerVersionRequested && service.Site.Id.Equals(site) && service.ClientAccessType == ClientAccessType.InternalNLBBypass)
                    {
                        if (uriVersions == null)
                        {
                            uriVersions = new SortedDictionary <int, List <WebServicesService> >();
                        }
                        int key2 = service.ServerVersionNumber >> 16;
                        if (!uriVersions.ContainsKey(key2))
                        {
                            uriVersions[key2] = new List <WebServicesService>();
                        }
                        uriVersions[key2].Add(service);
                    }
                }, "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MessageTracking\\ServerCache.cs", "GetCasServerUri", 674);
            }
            catch (ServiceDiscoveryTransientException ex)
            {
                TraceWrapper.SearchLibraryTracer.TraceError <ServiceDiscoveryTransientException>(this.GetHashCode(), "Transient exception getting Internal CAS URI: {0}", ex);
                TrackingTransientException.RaiseETX(ErrorCode.CASUriDiscoveryFailure, site.ToString(), ex.ToString());
            }
            catch (ServiceDiscoveryPermanentException ex2)
            {
                TraceWrapper.SearchLibraryTracer.TraceError <ServiceDiscoveryPermanentException>(this.GetHashCode(), "Permanent exception getting Internal CAS URI: {0}", ex2);
                TrackingFatalException.RaiseETX(ErrorCode.CASUriDiscoveryFailure, site.ToString(), ex2.ToString());
            }
            if (uriVersions != null && uriVersions.Count > 0)
            {
                int key = uriVersions.Last <KeyValuePair <int, List <WebServicesService> > >().Key;
                List <WebServicesService> value = uriVersions.Last <KeyValuePair <int, List <WebServicesService> > >().Value;
                int index = ServerCache.rand.Next(value.Count);
                WebServicesService webServicesService = value.ElementAt(index);
                TraceWrapper.SearchLibraryTracer.TraceDebug <Uri, string>(this.GetHashCode(), "Using CAS URI: {0}, Version {1}", webServicesService.Url, new ServerVersion(webServicesService.ServerVersionNumber).ToString());
                serverVersion = webServicesService.ServerVersionNumber;
                return(webServicesService.Url);
            }
            TraceWrapper.SearchLibraryTracer.TraceError <string, string>(this.GetHashCode(), "Failed to find any CAS server in site: {0}, with min version {1}", site.ToString(), new ServerVersion(minServerVersionRequested).ToString());
            return(null);
        }
        // Token: 0x06000554 RID: 1364 RVA: 0x0001D684 File Offset: 0x0001B884
        private static Uri FindRedirectEcpUrlCrossSite(Site targetSite, int expectedMajorVersion, out FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause failureCause)
        {
            failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None;
            EcpService clientExternalService = null;

            ServiceTopology.GetCurrentServiceTopology("d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectEcpUrlCrossSite", 471).ForEach <EcpService>(delegate(EcpService ecpService)
            {
                if (ServiceTopology.IsOnSite(ecpService, targetSite, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectEcpUrlCrossSite", 477) && ecpService.ClientAccessType == 1 && OwaServerVersion.CreateFromVersionNumber(ecpService.ServerVersionNumber).Major == expectedMajorVersion)
                {
                    clientExternalService = ecpService;
                }
            }, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectEcpUrlCrossSite", 474);
            if (clientExternalService != null)
            {
                return(clientExternalService.Url);
            }
            failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.NoCasFound;
            return(null);
        }
        // Token: 0x06000817 RID: 2071 RVA: 0x00021178 File Offset: 0x0001F378
        private Dictionary <Guid, BackEndServer> ProcessBatchResults(DatabaseServerInformation[] backEndServerList)
        {
            if (backEndServerList == null || backEndServerList.Length == 0)
            {
                this.Tracer.TraceError <string, Guid>((long)this.GetHashCode(), "[MailboxServerLocator.ProcessBatchResults] ServerLocatorServiceClient did not return active server info from master server {0} for database {1}.", this.masterServer.Fqdn, this.DatabaseGuid);
                throw new MailboxServerLocatorException(this.DatabaseGuid.ToString());
            }
            this.Tracer.TraceDebug <int, string, Guid>((long)this.GetHashCode(), "[MailboxServerLocator.ProcessBatchResults] ServerLocatorServiceClient returned {0} servers from master server {0} for database {1}.", backEndServerList.Length, this.masterServer.Fqdn, this.DatabaseGuid);
            Dictionary <Guid, BackEndServer> dictionary = new Dictionary <Guid, BackEndServer>(backEndServerList.Length);

            foreach (DatabaseServerInformation databaseServerInformation in backEndServerList)
            {
                if (string.IsNullOrEmpty(databaseServerInformation.ServerFqdn))
                {
                    this.Tracer.TraceWarning <string, Guid>((long)this.GetHashCode(), "[MailboxServerLocator.ProcessBatchResults] ServerLocatorServiceClient returned empty active server FQDN from master server {0} for database {1}.", this.masterServer.Fqdn, databaseServerInformation.DatabaseGuid);
                }
                else
                {
                    if (databaseServerInformation.ServerVersion == 0)
                    {
                        this.Tracer.TraceWarning <string, string, Guid>((long)this.GetHashCode(), "[MailboxServerLocator.ProcessBatchResults] ServerLocatorServiceClient returned empty active server version of server {0} from master server {1} for database {2}.", databaseServerInformation.ServerFqdn, this.masterServer.Fqdn, databaseServerInformation.DatabaseGuid);
                        databaseServerInformation.ServerVersion = this.masterServer.VersionNumber;
                        if (!MailboxServerLocator.NoServiceTopologyTryGetServerVersion)
                        {
                            ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\MailboxServerLocator.cs", "ProcessBatchResults", 985);
                            int             serverVersion;
                            if (currentServiceTopology.TryGetServerVersion(databaseServerInformation.ServerFqdn, out serverVersion, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\MailboxServerLocator.cs", "ProcessBatchResults", 986))
                            {
                                databaseServerInformation.ServerVersion = serverVersion;
                            }
                        }
                    }
                    this.Tracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "[MailboxServerLocator.ProcessBatchResults] The active server of database {0} is {1}.", databaseServerInformation.DatabaseGuid, databaseServerInformation.ServerFqdn);
                    dictionary[databaseServerInformation.DatabaseGuid] = new BackEndServer(databaseServerInformation.ServerFqdn, databaseServerInformation.ServerVersion);
                }
            }
            if (!dictionary.ContainsKey(this.DatabaseGuid))
            {
                this.Tracer.TraceWarning <string, Guid>((long)this.GetHashCode(), "[MailboxServerLocator.ProcessBatchResults] ServerLocatorServiceClient did not return the active server of database {1} from master server {0}.", this.masterServer.Fqdn, this.DatabaseGuid);
                throw new MissingRequestedDatabaseException(this.DatabaseGuid.ToString());
            }
            return(dictionary);
        }
Пример #13
0
        // Token: 0x06000391 RID: 913 RVA: 0x000161C0 File Offset: 0x000143C0
        internal static Uri GetRandomCasExternalServiceUri <T>(ExchangeVersion?requestedVersion, out int serverVersion) where T : HttpService
        {
            Dictionary <Uri, int> uriMinimumVersions = null;

            serverVersion = 0;
            try
            {
                ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\autodisc\\src\\WCF\\Requests\\GetDomainSettingsRequestMessage.cs", "GetRandomCasExternalServiceUri", 101);
                int             minimumVersionNeeded   = GetDomainSettingsRequestMessage.GetMinimumServerVersionForExchangeVersion(requestedVersion);
                currentServiceTopology.ForEach <T>(delegate(T service)
                {
                    if (service.ServerVersionNumber >= minimumVersionNeeded && service.ClientAccessType == ClientAccessType.External)
                    {
                        if (uriMinimumVersions == null)
                        {
                            uriMinimumVersions = new Dictionary <Uri, int>(10);
                        }
                        int num;
                        if (!uriMinimumVersions.TryGetValue(service.Url, out num) || num > service.ServerVersionNumber)
                        {
                            uriMinimumVersions[service.Url] = service.ServerVersionNumber;
                        }
                    }
                }, "f:\\15.00.1497\\sources\\dev\\autodisc\\src\\WCF\\Requests\\GetDomainSettingsRequestMessage.cs", "GetRandomCasExternalServiceUri", 105);
            }
            catch (ServiceDiscoveryTransientException arg)
            {
                ExTraceGlobals.FrameworkTracer.TraceError <ServiceDiscoveryTransientException>(0L, "GetRandomCasExternalServiceUri encountered transient exception: {0}", arg);
            }
            catch (ServiceDiscoveryPermanentException arg2)
            {
                ExTraceGlobals.FrameworkTracer.TraceError <ServiceDiscoveryPermanentException>(0L, "GetRandomCasExternalServiceUri encountered permanent exception: {0}", arg2);
            }
            if (uriMinimumVersions == null)
            {
                return(null);
            }
            int index = GetDomainSettingsRequestMessage.random.Next(uriMinimumVersions.Count);
            Uri uri   = uriMinimumVersions.Keys.ElementAt(index);

            serverVersion = uriMinimumVersions[uri];
            return(uri);
        }
        private static Uri FindRedirectEcpUrlCrossSite(Site targetSite, int expectedMajorVersion, out FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause failureCause)
        {
            failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None;
            EcpService      clientExternalService  = null;
            ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectEcpUrlCrossSite", 470);

            currentServiceTopology.ForEach <EcpService>(delegate(EcpService ecpService)
            {
                if (ServiceTopology.IsOnSite(ecpService, targetSite, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectEcpUrlCrossSite", 476) && ecpService.ClientAccessType == ClientAccessType.External)
                {
                    int major = OwaServerVersion.CreateFromVersionNumber(ecpService.ServerVersionNumber).Major;
                    if (major == expectedMajorVersion)
                    {
                        clientExternalService = ecpService;
                    }
                }
            }, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectEcpUrlCrossSite", 473);
            if (clientExternalService != null)
            {
                return(clientExternalService.Url);
            }
            failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.NoCasFound;
            return(null);
        }
        private void HandleFbaFormPost(BackEndServer backEndServer)
        {
            HttpContext      httpContext            = base.HttpContext;
            HttpResponse     response               = httpContext.Response;
            Uri              uri                    = null;
            string           text                   = httpContext.Items["destination"] as string;
            bool             flag                   = false;
            bool             flag2                  = false;
            bool             flag3                  = true;
            string           fqdn                   = backEndServer.Fqdn;
            int              version                = backEndServer.Version;
            OwaServerVersion owaServerVersion       = null;
            bool             flag4                  = false;
            ServiceTopology  currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "HandleFbaFormPost", 780);
            Site             site                   = currentServiceTopology.GetSite(fqdn, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "HandleFbaFormPost", 781);

            if (site != null && !site.Equals(HttpProxyGlobals.LocalSite.Member))
            {
                flag3 = false;
            }
            if (!FbaFormPostProxyRequestHandler.DisableSSORedirects)
            {
                owaServerVersion = OwaServerVersion.CreateFromVersionNumber(version);
                if (UrlUtilities.IsEcpUrl(text) && owaServerVersion.Major < (int)ExchangeObjectVersion.Exchange2010.ExchangeBuild.Major)
                {
                    flag  = false;
                    flag2 = false;
                }
                else if (!flag3 && !UserAgentParser.IsMonitoringRequest(base.ClientRequest.UserAgent))
                {
                    if (owaServerVersion.Major >= (int)ExchangeObjectVersion.Exchange2007.ExchangeBuild.Major)
                    {
                        FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause legacyRedirectFailureCause = FbaFormPostProxyRequestHandler.NeedCrossSiteRedirect(backEndServer, site, HttpProxyGlobals.LocalSite.Member, owaServerVersion, UrlUtilities.IsEcpUrl(text), out uri, out flag4);
                        string authority = base.ClientRequest.Url.Authority;
                        string b         = (uri == null) ? string.Empty : uri.Authority;
                        flag2 = (legacyRedirectFailureCause != FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.NoCasFound && !string.Equals(authority, b, StringComparison.OrdinalIgnoreCase) && (legacyRedirectFailureCause != FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None || uri != null));
                        if (uri == null && owaServerVersion.Major == (int)ExchangeObjectVersion.Exchange2007.ExchangeBuild.Major)
                        {
                            flag = (FbaFormPostProxyRequestHandler.NeedOnSiteLegacyRedirect(backEndServer, null, HttpProxyGlobals.LocalSite.Member, owaServerVersion, out uri, out flag4) != FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None || uri != null);
                        }
                    }
                }
                else
                {
                    flag = (FbaFormPostProxyRequestHandler.NeedOnSiteLegacyRedirect(backEndServer, site, HttpProxyGlobals.LocalSite.Member, owaServerVersion, out uri, out flag4) != FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None || uri != null);
                }
            }
            if (flag2 || flag)
            {
                if (uri != null)
                {
                    string authority2 = base.ClientRequest.Url.Authority;
                    string authority3 = uri.Authority;
                    if (string.Compare(authority2, authority3, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        throw new HttpException(403, "Redirect loop detected");
                    }
                }
                using (SecureNameValueCollection secureNameValueCollection = new SecureNameValueCollection())
                {
                    int num = (int)base.HttpContext.Items["flags"];
                    secureNameValueCollection.AddUnsecureNameValue("destination", base.HttpContext.Items["destination"] as string);
                    secureNameValueCollection.AddUnsecureNameValue("username", base.HttpContext.Items["username"] as string);
                    secureNameValueCollection.AddUnsecureNameValue("flags", num.ToString(CultureInfo.InvariantCulture));
                    using (SecureString secureString = base.HttpContext.Items["password"] as SecureString)
                    {
                        secureNameValueCollection.AddSecureNameValue("password", secureString);
                        if (flag)
                        {
                            if (uri == null)
                            {
                                AspNetHelper.TransferToErrorPage(httpContext, ErrorFE.FEErrorCodes.NoLegacyCAS);
                            }
                            else if (flag4)
                            {
                                if (uri.Scheme == Uri.UriSchemeHttps)
                                {
                                    ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "FbaFormPostProxyRequestHandler - SSO redirecting to {0}", uri.ToString());
                                    this.RedirectUsingSSOFBA(secureNameValueCollection, uri, response, owaServerVersion.Major);
                                    response.End();
                                }
                                else
                                {
                                    AspNetHelper.TransferToErrorPage(httpContext, ErrorFE.FEErrorCodes.NoFbaSSL);
                                }
                            }
                            else
                            {
                                ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "FbaFormPostProxyRequestHandler - redirecting to {0}", uri.ToString());
                                base.PfdTracer.TraceRedirect("FbaAuth", uri.ToString());
                                response.Redirect(FbaFormPostProxyRequestHandler.CheckRedirectUrlForNewline(uri.ToString()));
                            }
                        }
                        else if (flag2)
                        {
                            if (uri == null)
                            {
                                AspNetHelper.TransferToErrorPage(httpContext, ErrorFE.FEErrorCodes.NoLegacyCAS);
                            }
                            else
                            {
                                Uri uri2 = uri;
                                if (this.explicitLogonUser != null)
                                {
                                    uri2 = FbaFormPostProxyRequestHandler.AppendSmtpAddressToUrl(uri, this.explicitLogonUser);
                                }
                                if (flag4)
                                {
                                    if (uri.Scheme == Uri.UriSchemeHttps)
                                    {
                                        ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "FbaFormPostProxyRequestHandler - SSO redirecting to {0}", uri.ToString());
                                        this.RedirectUsingSSOFBA(secureNameValueCollection, uri, response, owaServerVersion.Major);
                                        response.End();
                                    }
                                    else
                                    {
                                        AspNetHelper.TransferToErrorPage(httpContext, ErrorFE.FEErrorCodes.NoFbaSSL);
                                    }
                                }
                                else
                                {
                                    ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "FbaFormPostProxyRequestHandler - redirecting to {0}", uri2.ToString());
                                    base.PfdTracer.TraceRedirect("FbaAuth", uri2.ToString());
                                    response.Redirect(FbaFormPostProxyRequestHandler.CheckRedirectUrlForNewline(uri2.ToString()));
                                }
                            }
                        }
                    }
                    return;
                }
            }
            try
            {
                FbaModule.SetCadataCookies(base.HttpApplication);
            }
            catch (MissingSslCertificateException)
            {
                AspNetHelper.TransferToErrorPage(httpContext, ErrorFE.FEErrorCodes.NoFbaSSL);
            }
            ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "FbaFormPostProxyRequestHandler - redirecting to {0}", text);
            base.PfdTracer.TraceRedirect("FbaAuth", text);
            response.Redirect(FbaFormPostProxyRequestHandler.CheckRedirectUrlForNewline(text), false);
        }
        // Token: 0x06000556 RID: 1366 RVA: 0x0001D77C File Offset: 0x0001B97C
        private static Uri FindRedirectOwaUrlOnSiteForMismatchVersion(Site targetSite, int expectedMajorVersion, AuthenticationMethod internalAutheticationMethod, AuthenticationMethod externalAuthenticationMethod, BackEndServer backEndServer, out bool isSameAuthMethod, out FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause failureCause)
        {
            failureCause     = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None;
            isSameAuthMethod = true;
            bool            isSameAuthInternalService = false;
            bool            isSameAuthExternalService = false;
            OwaService      clientInternalService     = null;
            OwaService      clientExternalService     = null;
            string          mailboxServerFQDN         = backEndServer.Fqdn;
            ServiceTopology currentServiceTopology    = ServiceTopology.GetCurrentServiceTopology("d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlOnSiteForMismatchVersion", 578);

            new List <OwaService>();
            currentServiceTopology.ForEach <OwaService>(delegate(OwaService owaService)
            {
                if (ServiceTopology.IsOnSite(owaService, targetSite, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlOnSiteForMismatchVersion", 587))
                {
                    if (owaService.ClientAccessType == 1)
                    {
                        if (OwaServerVersion.CreateFromVersionNumber(owaService.ServerVersionNumber).Major == expectedMajorVersion)
                        {
                            bool flag = false;
                            if (owaService.AuthenticationMethod == internalAutheticationMethod || ((internalAutheticationMethod & 4) != null && (owaService.AuthenticationMethod & 4) != null))
                            {
                                flag = true;
                                if (!isSameAuthExternalService)
                                {
                                    clientExternalService     = null;
                                    isSameAuthExternalService = true;
                                }
                            }
                            if (flag || !isSameAuthExternalService)
                            {
                                if (clientExternalService == null)
                                {
                                    clientExternalService = owaService;
                                    return;
                                }
                                if (ServiceTopology.CasMbxServicesFirst(owaService, clientExternalService, mailboxServerFQDN, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlOnSiteForMismatchVersion", 618) < 0)
                                {
                                    clientExternalService = owaService;
                                    return;
                                }
                            }
                        }
                    }
                    else if (owaService.ClientAccessType == null && OwaServerVersion.CreateFromVersionNumber(owaService.ServerVersionNumber).Major == expectedMajorVersion && clientExternalService == null)
                    {
                        bool flag = false;
                        if (owaService.AuthenticationMethod == internalAutheticationMethod || ((internalAutheticationMethod & 4) != null && (owaService.AuthenticationMethod & 4) != null))
                        {
                            flag = true;
                            if (!isSameAuthInternalService)
                            {
                                clientInternalService     = null;
                                isSameAuthInternalService = true;
                            }
                        }
                        if (flag || !isSameAuthInternalService)
                        {
                            if (clientInternalService == null)
                            {
                                clientInternalService = owaService;
                                return;
                            }
                            if (ServiceTopology.CasMbxServicesFirst(owaService, clientInternalService, mailboxServerFQDN, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlOnSiteForMismatchVersion", 657) > 0)
                            {
                                clientInternalService = owaService;
                            }
                        }
                    }
                }
            }, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlOnSiteForMismatchVersion", 582);
            if (clientExternalService != null)
            {
                isSameAuthMethod = isSameAuthExternalService;
                return(clientExternalService.Url);
            }
            if (clientInternalService != null)
            {
                isSameAuthMethod = isSameAuthInternalService;
                return(clientInternalService.Url);
            }
            failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.NoCasFound;
            return(null);
        }
        // Token: 0x06000230 RID: 560 RVA: 0x0000D4F0 File Offset: 0x0000B6F0
        protected override void WriteConfigXml(XmlWriter xmlFragment)
        {
            if (base.RequestedRecipient == null)
            {
                this.WriteErrorResponse(xmlFragment, "2", Strings.MobileSyncAddressNotFound.ToString(), string.Empty, base.RequestData, null, null);
                return;
            }
            if (base.RequestedRecipient.RecipientType != RecipientType.UserMailbox)
            {
                this.WriteErrorResponse(xmlFragment, "9", Strings.MobileSyncBadAddress.ToString(), base.RequestedRecipient.RecipientType.ToString(), base.RequestData, base.RequestedRecipient.DisplayName, base.RequestedRecipient.PrimarySmtpAddress.ToString());
                return;
            }
            ADUser            adUser            = base.RequestedRecipient as ADUser;
            ExchangePrincipal exchangePrincipal = Common.GetExchangePrincipal(adUser);

            if (exchangePrincipal == null)
            {
                this.WriteErrorResponse(xmlFragment, "1", Strings.ActiveDirectoryFailure.ToString(), base.RequestedRecipient.RecipientType.ToString(), base.RequestData, base.RequestedRecipient.DisplayName, base.RequestedRecipient.PrimarySmtpAddress.ToString());
                return;
            }
            string mobileName   = null;
            string certUrl      = null;
            string certTemplate = null;
            bool   certEnabled  = false;
            VariantConfigurationSnapshot configuration = exchangePrincipal.GetConfiguration();

            if (Common.SkipServiceTopologyInDatacenter(configuration))
            {
                Uri datacenterFrontEndEasUrl = FrontEndLocator.GetDatacenterFrontEndEasUrl();
                if (datacenterFrontEndEasUrl != null)
                {
                    mobileName = datacenterFrontEndEasUrl.ToString();
                }
            }
            else
            {
                ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\autodisc\\src\\Providers\\MobileSync\\Web\\MobileSyncProvider.cs", "WriteConfigXml", 376);
                Site            site = currentServiceTopology.GetSite(exchangePrincipal.MailboxInfo.Location.ServerFqdn, "f:\\15.00.1497\\sources\\dev\\autodisc\\src\\Providers\\MobileSync\\Web\\MobileSyncProvider.cs", "WriteConfigXml", 377);
                SiteCostComparer <MobileSyncService> comparer = new SiteCostComparer <MobileSyncService>(currentServiceTopology, site);
                MobileSyncService cheapest        = null;
                MobileSyncService cheapestToProxy = null;
                currentServiceTopology.ForEach <MobileSyncService>(delegate(MobileSyncService service)
                {
                    if (service.ClientAccessType == ClientAccessType.External)
                    {
                        if (service.ServerVersionNumber == exchangePrincipal.MailboxInfo.Location.ServerVersion && (cheapest == null || comparer.Compare(cheapest, service) > 0))
                        {
                            cheapest = service;
                            return;
                        }
                        if (cheapestToProxy == null || comparer.Compare(cheapestToProxy, service) > 0)
                        {
                            if (service.ServerVersionNumber > exchangePrincipal.MailboxInfo.Location.ServerVersion)
                            {
                                cheapestToProxy = service;
                                return;
                            }
                            ServerVersion serverVersion  = new ServerVersion(exchangePrincipal.MailboxInfo.Location.ServerVersion);
                            ServerVersion serverVersion2 = new ServerVersion(service.ServerVersionNumber);
                            if (serverVersion2.Major >= serverVersion.Major && serverVersion2.Minor >= serverVersion.Minor)
                            {
                                cheapestToProxy = service;
                            }
                        }
                    }
                }, "f:\\15.00.1497\\sources\\dev\\autodisc\\src\\Providers\\MobileSync\\Web\\MobileSyncProvider.cs", "WriteConfigXml", 388);
                if (cheapest == null && cheapestToProxy == null)
                {
                    this.WriteErrorResponse(xmlFragment, "1", Strings.ExternalUrlNotFound.ToString(), base.RequestedRecipient.RecipientType.ToString(), base.RequestData, base.RequestedRecipient.DisplayName, base.RequestedRecipient.PrimarySmtpAddress.ToString());
                    return;
                }
                if (cheapest == null || (cheapestToProxy != null && comparer.Compare(cheapest, cheapestToProxy) > 0))
                {
                    cheapest = cheapestToProxy;
                }
                mobileName   = cheapest.Url.ToString();
                certUrl      = cheapest.CertificateAuthorityUrl;
                certTemplate = cheapest.CertEnrollTemplateName;
                certEnabled  = cheapest.IsCertEnrollEnabled;
            }
            Common.StartEnvelope(xmlFragment);
            xmlFragment.WriteStartElement("Response", this.ResponseNs);
            xmlFragment.WriteElementString("Culture", this.ResponseNs, MobileSyncProvider.defaultCulture);
            this.WriteUserFragment(xmlFragment, base.RequestedRecipient.DisplayName, base.RequestedRecipient.PrimarySmtpAddress.ToString());
            xmlFragment.WriteStartElement("Action", this.ResponseNs);
            xmlFragment.WriteStartElement("Settings", this.ResponseNs);
            this.WriteServerFragment(xmlFragment, mobileName, certUrl, certTemplate, certEnabled);
            xmlFragment.WriteEndElement();
            this.WriteMailboxesFragment(xmlFragment, exchangePrincipal);
            xmlFragment.WriteEndElement();
            xmlFragment.WriteEndElement();
            Common.EndEnvelope(xmlFragment);
            Common.EventLog.LogEvent(AutodiscoverEventLogConstants.Tuple_InfoProvConfigurationResponse, Common.PeriodicKey, new object[]
            {
                (base.RequestData.LegacyDN == null) ? base.RequestData.EMailAddress : base.RequestData.LegacyDN
            });
            RequestDetailsLoggerBase <RequestDetailsLogger> .Current.AppendGenericInfo("MobileSyncConfigSuccess", base.RequestData.LegacyDN ?? base.RequestData.EMailAddress);
        }
Пример #18
0
        private static HttpProxyBackEndHelper.TopologyWithSites GetCompleteServiceTopologyWithSites(string serverFqdn)
        {
            ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetCompleteServiceTopologyWithSites", 1040);

            return(HttpProxyBackEndHelper.GetServiceTopologyWithSites(serverFqdn, currentServiceTopology));
        }
Пример #19
0
        private static ADUser GetOrganizationMailboxInClosestSite(IRecipientSession recipientSession, OrganizationCapability capability)
        {
            if (recipientSession == null)
            {
                throw new ArgumentNullException("recipientSession");
            }
            List <ADUser> organizationMailboxesByCapability = OrganizationMailbox.GetOrganizationMailboxesByCapability(recipientSession, capability);

            if (organizationMailboxesByCapability == null || organizationMailboxesByCapability.Count == 0)
            {
                ExTraceGlobals.CafeTracer.TraceError <OrganizationCapability, OrganizationId>(0L, "[HttpProxyBackEndHelper.GetOrganizationMailbox] Unable to find organization mailbox with capability {0} for organization {1}.", capability, recipientSession.SessionSettings.CurrentOrganizationId);
                return(null);
            }
            ADUser aduser;

            if (organizationMailboxesByCapability.Count == 1)
            {
                aduser = organizationMailboxesByCapability[0];
            }
            else
            {
                ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetOrganizationMailboxInClosestSite", 753);
                Site            site = currentServiceTopology.GetSite(LocalServerCache.LocalServerFqdn, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetOrganizationMailboxInClosestSite", 754);
                List <ADUser>   list = new List <ADUser>(5);
                int             num  = int.MaxValue;
                foreach (ADUser aduser2 in organizationMailboxesByCapability)
                {
                    ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(recipientSession.SessionSettings, aduser2, RemotingOptions.AllowCrossSite);
                    Site site2 = currentServiceTopology.GetSite(exchangePrincipal.MailboxInfo.Location.ServerFqdn, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetOrganizationMailboxInClosestSite", 761);
                    if (list.Count == 0)
                    {
                        list.Add(aduser2);
                        currentServiceTopology.TryGetConnectionCost(site, site2, out num, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetOrganizationMailboxInClosestSite", 768);
                    }
                    else
                    {
                        int maxValue = int.MaxValue;
                        currentServiceTopology.TryGetConnectionCost(site, site2, out maxValue, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetOrganizationMailboxInClosestSite", 773);
                        if (maxValue == num)
                        {
                            list.Add(aduser2);
                        }
                        else if (maxValue < num)
                        {
                            list.Clear();
                            list.Add(aduser2);
                            num = maxValue;
                        }
                    }
                }
                if (list.Count == 1)
                {
                    aduser = list[0];
                }
                else
                {
                    aduser = list[HttpProxyBackEndHelper.random.Next(list.Count)];
                }
            }
            ExTraceGlobals.CafeTracer.TraceDebug <ObjectId, OrganizationCapability, OrganizationId>(0L, "[HttpProxyBackEndHelper.GetOrganizationMailbox] Find organization mailbox {0} with capability {1} for organization {2}.", aduser.Identity, capability, recipientSession.SessionSettings.CurrentOrganizationId);
            return(aduser);
        }
Пример #20
0
        private Uri GetEcpUrl(ExchangePrincipal mailbox)
        {
            Uri       uri = null;
            Exception ex  = null;

            try
            {
                if (mailbox.MailboxInfo.Location.ServerVersion >= Server.E15MinVersion && GlobalSettings.IsMultiTenancyEnabled)
                {
                    uri = FrontEndLocator.GetFrontEndEcpUrl(mailbox);
                    AirSyncDiagnostics.TraceDebug <ExchangePrincipal, Uri>(ExTraceGlobals.RequestsTracer, null, "ABQMail:ECP URL for user {0} - {1} (E15 Multitenancy)", mailbox, uri);
                }
                else
                {
                    ServiceTopology    serviceTopology = GlobalSettings.IsMultiTenancyEnabled ? ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ABQMailHelper.cs", "GetEcpUrl", 605) : ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ABQMailHelper.cs", "GetEcpUrl", 605);
                    ServerVersion      serverVersion   = new ServerVersion(mailbox.MailboxInfo.Location.ServerVersion);
                    int                majorversion    = serverVersion.Major;
                    IList <EcpService> list            = serviceTopology.FindAll <EcpService>(mailbox, ClientAccessType.External, (EcpService service) => new ServerVersion(service.ServerVersionNumber).Major == majorversion, "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ABQMailHelper.cs", "GetEcpUrl", 610);
                    foreach (EcpService ecpService in list)
                    {
                        if (ecpService != null && ecpService.Url != null)
                        {
                            uri = ecpService.Url;
                            AirSyncDiagnostics.TraceDebug <ExchangePrincipal, Uri>(ExTraceGlobals.RequestsTracer, null, "ABQMail:ECP URL for user {0} - {1} (not E15 Multitenancy)", mailbox, uri);
                            break;
                        }
                    }
                }
            }
            catch (ServerNotFoundException ex2)
            {
                ex = ex2;
            }
            catch (ADTransientException ex3)
            {
                ex = ex3;
            }
            catch (DataSourceOperationException ex4)
            {
                ex = ex4;
            }
            catch (DataValidationException ex5)
            {
                ex = ex5;
            }
            finally
            {
                if (ex != null)
                {
                    AirSyncDiagnostics.TraceError <ExchangePrincipal, Exception>(ExTraceGlobals.RequestsTracer, null, "ABQMail:Could not retrieve ECP URL for user {0} - {1}", mailbox, ex);
                }
            }
            return(uri);
        }
        private string GetEnterpriseOrE14OwaServiceUrl(IExchangePrincipal exchangePrincipal)
        {
            ServiceTopology    serviceTopology = this.IsMultitenancyEnabled ? ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\StoreTasks\\UserOptions\\MailboxCalendarFolder\\SetMailboxCalendarFolder.cs", "GetEnterpriseOrE14OwaServiceUrl", 335) : ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\StoreTasks\\UserOptions\\MailboxCalendarFolder\\SetMailboxCalendarFolder.cs", "GetEnterpriseOrE14OwaServiceUrl", 335);
            IList <OwaService> list            = serviceTopology.FindAll <OwaService>(exchangePrincipal, ClientAccessType.External, SetMailboxCalendarFolder.serviceFilter, "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\StoreTasks\\UserOptions\\MailboxCalendarFolder\\SetMailboxCalendarFolder.cs", "GetEnterpriseOrE14OwaServiceUrl", 339);

            if (list.Count != 0)
            {
                return(list[0].Url.ToString());
            }
            OwaService owaService = serviceTopology.FindAny <OwaService>(ClientAccessType.External, SetMailboxCalendarFolder.serviceFilter, "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\StoreTasks\\UserOptions\\MailboxCalendarFolder\\SetMailboxCalendarFolder.cs", "GetEnterpriseOrE14OwaServiceUrl", 348);

            if (owaService == null)
            {
                throw new NoExternalOwaAvailableException();
            }
            return(owaService.Url.ToString());
        }
Пример #22
0
        public RbacSettings(HttpContext context)
        {
            ExTraceGlobals.RBACTracer.TraceInformation <string>(0, 0L, "Extracting RBAC settings from {0}.", context.GetRequestUrlForLog());
            Guid vdirId = Guid.Empty;

            Guid.TryParse(HttpContext.Current.Request.Headers["X-vDirObjectId"], out vdirId);
            this.ecpService = new Lazy <EcpService>(delegate()
            {
                if (vdirId == Guid.Empty)
                {
                    return(null);
                }
                ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\admin\\src\\ecp\\RBAC\\RbacSettings.cs", ".ctor", 707);
                return(currentServiceTopology.FindAnyCafeService <EcpService>((EcpService service) => service.ADObjectId.ObjectGuid == vdirId, "f:\\15.00.1497\\sources\\dev\\admin\\src\\ecp\\RBAC\\RbacSettings.cs", ".ctor", 708));
            });
            this.LogonUserIdentity = context.User.Identity;
            this.OriginalUser      = context.User;
            this.IsProxyLogon      = context.Request.FilePath.EndsWith("/proxyLogon.ecp", StringComparison.OrdinalIgnoreCase);
            bool flag = context.IsAcsOAuthRequest();

            if (this.IsProxyLogon)
            {
                this.ProxySecurityAccessToken = new SerializedAccessToken(context.Request.InputStream);
            }
            else
            {
                this.ProxySecurityAccessToken = null;
            }
            string logonAccountSddlSid = context.Request.Headers["msExchLogonAccount"];
            string text = context.Request.Headers["msExchLogonMailbox"];
            string targetMailboxSddlSid = context.Request.Headers["msExchTargetMailbox"];
            Server inboundProxyCaller   = RbacSettings.GetInboundProxyCaller(text, this.LogonUserIdentity as WindowsIdentity);

            if (inboundProxyCaller != null)
            {
                this.IsInboundProxyRequest  = true;
                this.InboundProxyCallerName = inboundProxyCaller.Name;
                EcpLogonInformation identity = EcpLogonInformation.Create(logonAccountSddlSid, text, targetMailboxSddlSid, this.ProxySecurityAccessToken);
                this.EcpIdentity = new EcpIdentity(identity, "-ProxySession");
            }
            else
            {
                this.IsInboundProxyRequest  = false;
                this.InboundProxyCallerName = string.Empty;
                string explicitUser = context.GetExplicitUser();
                string targetTenant = context.GetTargetTenant();
                string text2        = string.IsNullOrEmpty(targetTenant) ? "-RbacSession" : ("-RbacSession-@" + targetTenant);
                if (flag)
                {
                    text2 += "-OAuthACS";
                }
                if (!string.IsNullOrEmpty(explicitUser))
                {
                    this.EcpIdentity = new EcpIdentity(context.User, explicitUser, text2);
                }
                else
                {
                    this.EcpIdentity = new EcpIdentity(this.LogonUserIdentity, text2);
                }
            }
            this.UserUniqueKeyForCanary = this.GetUserUniqueKey();
            this.IsExplicitSignOn       = this.EcpIdentity.IsExplicitSignon;
            bool flag2 = null == context.Request.Cookies[RbacModule.SessionStateCookieName];

            if (flag2 && !flag)
            {
                context.Response.Cookies.Add(new HttpCookie(RbacModule.SessionStateCookieName, Guid.NewGuid().ToString())
                {
                    HttpOnly = true
                });
                this.CacheKey = this.GetCacheKey();
                this.ExpireSession();
            }
            else
            {
                this.CacheKey = this.GetCacheKey();
            }
            ExTraceGlobals.RBACTracer.TraceInformation(0, 0L, "RBAC Settings for {0}: UserName: {1}, IsNewBrowserWindow={2}, IsInboundProxyRequest={3}, InboundProxyCallerName={4}, HasCachedSession={5}", new object[]
            {
                context.GetRequestUrlForLog(),
                this.UserName,
                flag2,
                this.IsInboundProxyRequest,
                this.InboundProxyCallerName,
                this.CachedSession != null
            });
        }
Пример #23
0
        private static Uri GetFrontEndHttpServiceUrl <ServiceType>(IExchangePrincipal exchangePrincipal) where ServiceType : HttpService
        {
            if (exchangePrincipal == null)
            {
                throw new ArgumentNullException("exchangePrincipal");
            }
            if (exchangePrincipal.MailboxInfo.Location.ServerVersion >= Server.E15MinVersion && FrontEndLocator.IsDatacenter)
            {
                return(GlobalServiceUrls.GetExternalUrl <ServiceType>());
            }
            ServiceTopology     serviceTopology = FrontEndLocator.IsDatacenter ? ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\FrontEndLocator.cs", "GetFrontEndHttpServiceUrl", 276) : ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\FrontEndLocator.cs", "GetFrontEndHttpServiceUrl", 276);
            ServerVersion       serverVersion   = new ServerVersion(exchangePrincipal.MailboxInfo.Location.ServerVersion);
            int                 majorversion    = serverVersion.Major;
            IList <ServiceType> services        = serviceTopology.FindAll <ServiceType>(exchangePrincipal, ClientAccessType.External, (ServiceType service) => new ServerVersion(service.ServerVersionNumber).Major == majorversion, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\FrontEndLocator.cs", "GetFrontEndHttpServiceUrl", 281);
            Uri                 uri             = FrontEndLocator.FindServiceInList <ServiceType>(services);

            if (uri == null)
            {
                services = serviceTopology.FindAll <ServiceType>(exchangePrincipal, ClientAccessType.Internal, (ServiceType service) => new ServerVersion(service.ServerVersionNumber).Major == majorversion, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\FrontEndLocator.cs", "GetFrontEndHttpServiceUrl", 285);
                uri      = FrontEndLocator.FindServiceInList <ServiceType>(services);
            }
            if (uri != null)
            {
                ExTraceGlobals.CafeTracer.TraceDebug <string>(0L, "[FrontEndLocator.GetFrontEndHttpServiceUrl] Found HTTP service for the specified back end server {0}.", exchangePrincipal.MailboxInfo.Location.ServerFqdn);
                return(uri);
            }
            throw new ServerNotFoundException("Unable to find proper HTTP service.");
        }
Пример #24
0
        // Token: 0x060001FF RID: 511 RVA: 0x0000A0EC File Offset: 0x000082EC
        private void InternalRefresh()
        {
            Dictionary <string, List <DownLevelServerStatusEntry> > dictionary = this.downLevelServerMapGetter();
            int             num             = 0;
            int             num2            = 0;
            ServiceTopology serviceTopology = null;

            try
            {
                serviceTopology = ServiceTopology.GetCurrentServiceTopology(DownLevelServerPingManager.DownLevelServerPingServiceTopologyTimeout.Value, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerPingManager.cs", "InternalRefresh", 209);
            }
            catch (ReadTopologyTimeoutException)
            {
            }
            foreach (List <DownLevelServerStatusEntry> list in dictionary.Values)
            {
                foreach (DownLevelServerStatusEntry downLevelServerStatusEntry in list)
                {
                    if (serviceTopology != null && serviceTopology.IsServerOutOfService(downLevelServerStatusEntry.BackEndServer.Fqdn, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerPingManager.cs", "InternalRefresh", 220))
                    {
                        if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(2))
                        {
                            ExTraceGlobals.VerboseTracer.TraceWarning <BackEndServer>((long)this.GetHashCode(), "[DownLevelServerPingManager::InternalRefresh]: Skipping server {0} because it's marked as OutOfService.", downLevelServerStatusEntry.BackEndServer);
                        }
                        downLevelServerStatusEntry.IsHealthy = false;
                    }
                    else
                    {
                        Uri uri = this.pingStrategy.Member.BuildUrl(downLevelServerStatusEntry.BackEndServer.Fqdn);
                        Diagnostics.Logger.LogEvent(FrontEndHttpProxyEventLogConstants.Tuple_PingingDownLevelServer, downLevelServerStatusEntry.BackEndServer.Fqdn, new object[]
                        {
                            HttpProxyGlobals.ProtocolType.ToString(),
                            downLevelServerStatusEntry.BackEndServer.Fqdn,
                            uri
                        });
                        Exception ex = this.pingStrategy.Member.Ping(uri);
                        if (ex != null)
                        {
                            ex = this.pingStrategy.Member.Ping(uri);
                        }
                        if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                        {
                            ExTraceGlobals.VerboseTracer.TraceDebug <Uri, Exception>((long)this.GetHashCode(), "[DownLevelServerPingManager::InternalRefresh]: Tested endpoint {0} with result {1}.", uri, ex);
                        }
                        if (ex != null)
                        {
                            downLevelServerStatusEntry.IsHealthy = false;
                            Diagnostics.Logger.LogEvent(FrontEndHttpProxyEventLogConstants.Tuple_MarkingDownLevelServerUnhealthy, downLevelServerStatusEntry.BackEndServer.Fqdn, new object[]
                            {
                                HttpProxyGlobals.ProtocolType.ToString(),
                                downLevelServerStatusEntry.BackEndServer.Fqdn,
                                uri,
                                ex.ToString()
                            });
                        }
                        else
                        {
                            num2++;
                            downLevelServerStatusEntry.IsHealthy = true;
                        }
                    }
                    num++;
                }
            }
            PerfCounters.HttpProxyCountersInstance.DownLevelTotalServers.RawValue   = (long)num;
            PerfCounters.HttpProxyCountersInstance.DownLevelHealthyServers.RawValue = (long)num2;
        }
Пример #25
0
        internal static BackEndServer GetAnyBackEndServerForVersion <ServiceType>(ServerVersion serverVersion, bool exactVersionMatch, ClientAccessType clientAccessType, bool currentSiteOnly = false) where ServiceType : HttpService
        {
            if (serverVersion == null)
            {
                throw new ArgumentNullException("version");
            }
            ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 349);
            string          empty               = string.Empty;
            int             version             = 0;
            ServerRole      serverRoleToLookFor = (serverVersion.Major < 15) ? ServerRole.ClientAccess : ServerRole.Mailbox;

            if (currentServiceTopology.TryGetRandomServerFromCurrentSite(serverRoleToLookFor, serverVersion.ToInt(), ServiceTopology.RandomServerSearchType.ExactVersion, out empty, out version, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 358))
            {
                return(new BackEndServer(empty, version));
            }
            if (!exactVersionMatch)
            {
                ServerVersion serverVersion2 = new ServerVersion(serverVersion.Major, 0, 0, 0);
                if (currentServiceTopology.TryGetRandomServerFromCurrentSite(serverRoleToLookFor, serverVersion2.ToInt(), ServiceTopology.RandomServerSearchType.MinimumVersionMatchMajor, out empty, out version, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 374))
                {
                    return(new BackEndServer(empty, version));
                }
            }
            if (!currentSiteOnly)
            {
                HttpService httpService = currentServiceTopology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && !service.IsFrontEnd && (service.ServerRole & serverRoleToLookFor) == serverRoleToLookFor && !service.IsOutOfService && service.AdminDisplayVersionNumber == serverVersion, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 389);
                if (httpService != null)
                {
                    return(new BackEndServer(httpService.ServerFullyQualifiedDomainName, httpService.ServerVersionNumber));
                }
                if (!exactVersionMatch)
                {
                    new ServerVersion(serverVersion.Major, 0, 0, 0);
                    httpService = currentServiceTopology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && !service.IsFrontEnd && (service.ServerRole & serverRoleToLookFor) == serverRoleToLookFor && !service.IsOutOfService && service.ServerVersionNumber > serverVersion.ToInt() && new ServerVersion(service.ServerVersionNumber).Major == serverVersion.Major, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 408);
                    if (httpService != null)
                    {
                        return(new BackEndServer(httpService.ServerFullyQualifiedDomainName, httpService.ServerVersionNumber));
                    }
                }
            }
            if (!exactVersionMatch)
            {
                ServerVersion higherVersion = new ServerVersion(serverVersion.Major + 1, 0, 0, 0);
                ServerRole    higherVersionServerRoleToLookFor = (higherVersion.Major < 15) ? ServerRole.ClientAccess : ServerRole.Mailbox;
                if (currentServiceTopology.TryGetRandomServerFromCurrentSite(higherVersionServerRoleToLookFor, higherVersion.ToInt(), ServiceTopology.RandomServerSearchType.MinimumVersion, out empty, out version, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 431))
                {
                    return(new BackEndServer(empty, version));
                }
                if (!currentSiteOnly)
                {
                    HttpService httpService2 = currentServiceTopology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && !service.IsFrontEnd && (service.ServerRole & higherVersionServerRoleToLookFor) == higherVersionServerRoleToLookFor && !service.IsOutOfService && service.ServerVersionNumber > higherVersion.ToInt(), "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 444);
                    if (httpService2 != null)
                    {
                        return(new BackEndServer(httpService2.ServerFullyQualifiedDomainName, httpService2.ServerVersionNumber));
                    }
                }
            }
            string message = string.Format("Unable to find any backend server for version {0}.", serverVersion);

            throw new ServerNotFoundException(message, serverVersion.ToString());
        }