示例#1
0
 private static HttpProxyBackEndHelper.TopologyWithSites GetServiceTopologyWithSites(string serverFqdn, ServiceTopology topology)
 {
     if (string.IsNullOrEmpty(serverFqdn))
     {
         throw new ArgumentNullException("serverFqdn");
     }
     HttpProxyBackEndHelper.TopologyWithSites topologyWithSites = new HttpProxyBackEndHelper.TopologyWithSites
     {
         ServiceTopology = topology
     };
     try
     {
         topologyWithSites.TargetSite = topology.GetSite(serverFqdn, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetServiceTopologyWithSites", 1065);
     }
     catch (ServerNotInSiteException arg)
     {
         ExTraceGlobals.CafeTracer.TraceError <string, ServerNotInSiteException>(0L, "[HttpProxyBackEndHelper.GetServiceTopologyWithSites] Could not find site for server {0} - ServerNotInSiteException {1}", serverFqdn, arg);
     }
     catch (ServerNotFoundException arg2)
     {
         ExTraceGlobals.CafeTracer.TraceError <string, ServerNotFoundException>(0L, "[HttpProxyBackEndHelper.GetServiceTopologyWithSites] Could not find site for server {0} - ServerNotFoundException {1}", serverFqdn, arg2);
     }
     try
     {
         topologyWithSites.CurrentSite = HttpProxyBackEndHelper.localSite.Member;
     }
     catch (CannotGetSiteInfoException arg3)
     {
         ExTraceGlobals.CafeTracer.TraceError <string, CannotGetSiteInfoException>(0L, "[HttpProxyBackEndHelper.GetServiceTopologyWithSites] Could not find site for current server {0} - CannotGetSiteInfoException {1}", LocalServerCache.LocalServerFqdn, arg3);
     }
     return(topologyWithSites);
 }
 // 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));
                     }
                 }
             }
         }
     }
 }
 // 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);
 }
 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);
 }
示例#6
0
 public static bool TryGetSite(this ServiceTopology serviceTopology, string fqdn, out Site site)
 {
     if (serviceTopology == null)
     {
         throw new ArgumentNullException("serviceTopology");
     }
     if (string.IsNullOrEmpty(fqdn))
     {
         throw new ArgumentNullException("fqdn");
     }
     site = null;
     try
     {
         site = serviceTopology.GetSite(fqdn, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\Misc\\Extensions.cs", "TryGetSite", 495);
     }
     catch (ServerNotFoundException)
     {
         return(false);
     }
     catch (ServerNotInSiteException)
     {
         return(false);
     }
     return(true);
 }
示例#7
0
 // Token: 0x0600040F RID: 1039 RVA: 0x00017934 File Offset: 0x00015B34
 public static bool TryGetSite(this ServiceTopology serviceTopology, string fqdn, out Site site)
 {
     if (serviceTopology == null)
     {
         throw new ArgumentNullException("serviceTopology");
     }
     if (string.IsNullOrEmpty(fqdn))
     {
         throw new ArgumentNullException("fqdn");
     }
     site = null;
     try
     {
         site = serviceTopology.GetSite(fqdn, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\Misc\\Extensions.cs", "TryGetSite", 483);
     }
     catch (ServerNotFoundException)
     {
         return(false);
     }
     catch (ServerNotInSiteException)
     {
         return(false);
     }
     return(true);
 }
示例#8
0
        public BackEndServer GetDownLevelClientAccessServer <ServiceType>(AnchorMailbox anchorMailbox, BackEndServer mailboxServer, ClientAccessType clientAccessType, RequestDetailsLogger logger, bool calculateRedirectUrl, out Uri redirectUrl) where ServiceType : HttpService
        {
            if (anchorMailbox == null)
            {
                throw new ArgumentNullException("anchorMailbox");
            }
            if (mailboxServer == null)
            {
                throw new ArgumentNullException("mailboxServer");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (!DownLevelServerManager.IsApplicable)
            {
                throw new HttpProxyException(HttpStatusCode.NotFound, HttpProxySubErrorCode.EndpointNotFound, string.Format("{0} does not support down level server proxy.", HttpProxyGlobals.ProtocolType));
            }
            redirectUrl = null;
            if (mailboxServer.Version < Server.E14MinVersion)
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <int, int, string>((long)this.GetHashCode(), "[DownLevelServerManager::GetDownLevelClientAccessServer]: Found mailbox server version {0}, which was pre-E14 minimum version {1}, so returning mailbox server FQDN {2}", mailboxServer.Version, Server.E14MinVersion, mailboxServer.Fqdn);
                return(mailboxServer);
            }
            ServiceTopology currentLegacyServiceTopology = ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServer", 393);
            Site            site   = currentLegacyServiceTopology.GetSite(mailboxServer.Fqdn, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServer", 394);
            ServiceType     result = this.GetClientAccessServiceInSite <ServiceType>(currentLegacyServiceTopology, anchorMailbox, site, clientAccessType, (ServiceType service) => service.ServerVersionNumber >= Server.E14MinVersion && service.ServerVersionNumber < Server.E15MinVersion, logger);

            if (calculateRedirectUrl && !Utilities.IsPartnerHostedOnly && !VariantConfiguration.InvariantNoFlightingSnapshot.Cafe.NoCrossSiteRedirect.Enabled && result != null && !string.IsNullOrEmpty(result.ServerFullyQualifiedDomainName))
            {
                Site member = HttpProxyGlobals.LocalSite.Member;
                if (!member.DistinguishedName.Equals(result.Site.DistinguishedName))
                {
                    HttpService httpService = currentLegacyServiceTopology.FindAny <ServiceType>(ClientAccessType.External, (ServiceType externalService) => externalService != null && externalService.ServerFullyQualifiedDomainName.Equals(result.ServerFullyQualifiedDomainName, StringComparison.OrdinalIgnoreCase), "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServer", 419);
                    if (httpService != null)
                    {
                        redirectUrl = httpService.Url;
                    }
                }
            }
            return(new BackEndServer(result.ServerFullyQualifiedDomainName, result.ServerVersionNumber));
        }
示例#9
0
 public static bool IsServerDiscoverable(string fqdn)
 {
     if (string.IsNullOrEmpty(fqdn))
     {
         throw new ArgumentNullException("fqdn");
     }
     try
     {
         ServiceTopology currentLegacyServiceTopology = ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "IsServerDiscoverable", 176);
         currentLegacyServiceTopology.GetSite(fqdn, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "IsServerDiscoverable", 177);
     }
     catch (ServerNotFoundException)
     {
         return(false);
     }
     catch (ServerNotInSiteException)
     {
         return(false);
     }
     return(true);
 }
        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);
        }
示例#11
0
        public BackEndServer GetDownLevelClientAccessServerWithPreferredServer <ServiceType>(AnchorMailbox anchorMailbox, string preferredCasServerFqdn, ClientAccessType clientAccessType, RequestDetailsLogger logger, int destinationVersion) where ServiceType : HttpService
        {
            Predicate <ServiceType> predicate  = null;
            Predicate <ServiceType> predicate2 = null;

            if (anchorMailbox == null)
            {
                throw new ArgumentNullException("anchorMailbox");
            }
            if (string.IsNullOrEmpty(preferredCasServerFqdn))
            {
                throw new ArgumentException("preferredCasServerFqdn cannot be empty!");
            }
            ServiceTopology currentLegacyServiceTopology = ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServerWithPreferredServer", 253);
            Site            site = currentLegacyServiceTopology.GetSite(preferredCasServerFqdn, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServerWithPreferredServer", 254);
            Dictionary <string, List <DownLevelServerStatusEntry> > downLevelServerMap = this.GetDownLevelServerMap();
            List <DownLevelServerStatusEntry> list = null;

            if (!downLevelServerMap.TryGetValue(site.DistinguishedName, out list))
            {
                string text = string.Format("Unable to find site {0} in the down level server map.", site.DistinguishedName);
                ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetDownLevelClientAccessServerWithPreferredServer]: {0}", text);
                ThreadPool.QueueUserWorkItem(delegate(object o)
                {
                    this.RefreshServerMap(true);
                });
                throw new NoAvailableDownLevelBackEndException(text);
            }
            DownLevelServerStatusEntry downLevelServerStatusEntry = list.Find((DownLevelServerStatusEntry backend) => preferredCasServerFqdn.Equals(backend.BackEndServer.Fqdn, StringComparison.OrdinalIgnoreCase));

            if (downLevelServerStatusEntry == null)
            {
                string text2 = string.Format("Unable to find preferred server {0} in the back end server map.", preferredCasServerFqdn);
                ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetDownLevelClientAccessServerWithPreferredServer]: {0}", text2);
                throw new NoAvailableDownLevelBackEndException(text2);
            }
            if (downLevelServerStatusEntry.IsHealthy)
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <DownLevelServerStatusEntry>((long)this.GetHashCode(), "[DownLevelServerManager::GetDownLevelClientAccessServerWithPreferredServer]: The preferred server {0} is healthy.", downLevelServerStatusEntry);
                return(downLevelServerStatusEntry.BackEndServer);
            }
            ServiceType serviceType = default(ServiceType);

            if (destinationVersion < Server.E14MinVersion)
            {
                try
                {
                    List <DownLevelServerStatusEntry> serverList = list;
                    ServiceTopology topology   = currentLegacyServiceTopology;
                    Site            targetSite = site;
                    if (predicate == null)
                    {
                        predicate = ((ServiceType service) => service.ServerVersionNumber >= Server.E2007MinVersion && service.ServerVersionNumber < Server.E14MinVersion);
                    }
                    serviceType = this.GetClientAccessServiceFromList <ServiceType>(serverList, topology, anchorMailbox, targetSite, clientAccessType, predicate, logger, DownLevelServerManager.DownlevelExchangeServerVersion.Exchange2007);
                }
                catch (NoAvailableDownLevelBackEndException)
                {
                    ExTraceGlobals.VerboseTracer.TraceError((long)this.GetHashCode(), "[DownLevelServerManager::GetDownLevelClientAccessServerWithPreferredServer]: No E12 CAS could be found for E12 destination. Looking for E14 CAS.");
                }
            }
            if (serviceType == null)
            {
                List <DownLevelServerStatusEntry> serverList2 = list;
                ServiceTopology topology2   = currentLegacyServiceTopology;
                Site            targetSite2 = site;
                if (predicate2 == null)
                {
                    predicate2 = ((ServiceType service) => service.ServerVersionNumber >= Server.E14MinVersion && service.ServerVersionNumber < Server.E15MinVersion);
                }
                serviceType = this.GetClientAccessServiceFromList <ServiceType>(serverList2, topology2, anchorMailbox, targetSite2, clientAccessType, predicate2, logger, DownLevelServerManager.DownlevelExchangeServerVersion.Exchange2010);
            }
            return(new BackEndServer(serviceType.ServerFullyQualifiedDomainName, serviceType.ServerVersionNumber));
        }
        // 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);
        }
示例#13
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);
        }