// 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);
 }
 // 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));
                     }
                 }
             }
         }
     }
 }
Пример #3
0
        // Token: 0x060005DF RID: 1503 RVA: 0x00020D48 File Offset: 0x0001EF48
        private bool TryGetMiniServerFromPartitionId(string partitionId, out MiniServer server)
        {
            bool result;

            try
            {
                if (CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).UseServerNameAsPartitionId.Enabled)
                {
                    bool flag;
                    server = ServersCache.GetServerOrDCByName(partitionId, ref flag);
                }
                else
                {
                    Guid guid;
                    if (!Guid.TryParse(partitionId, out guid))
                    {
                        base.Logger.AppendGenericError("Get server by partitionID exception", "Not a GUID");
                        server = null;
                        return(false);
                    }
                    bool flag;
                    server = ServersCache.GetServerOrDCByObjectGuid(guid, ref flag);
                }
                result = true;
            }
            catch (ObjectNotFoundException ex)
            {
                base.Logger.AppendGenericError("Get server by partitionID exception", ex.ToString());
                server = null;
                result = false;
            }
            return(result);
        }
 // Token: 0x060006F6 RID: 1782 RVA: 0x000290E8 File Offset: 0x000272E8
 protected override void SetUseServerCookieFlag(AnchorMailbox anchorMailbox)
 {
     if (CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).GenerateServerCookieInRPS.Enabled)
     {
         DatabaseBasedAnchorMailbox databaseBasedAnchorMailbox = anchorMailbox as DatabaseBasedAnchorMailbox;
         if (databaseBasedAnchorMailbox != null)
         {
             databaseBasedAnchorMailbox.UseServerCookie = true;
         }
     }
 }
Пример #5
0
 // Token: 0x060005CE RID: 1486 RVA: 0x000204DC File Offset: 0x0001E6DC
 protected override void HandleLogoffRequest()
 {
     if (base.ClientRequest != null && base.ClientResponse != null && base.ClientRequest.Url.AbsolutePath.EndsWith("/logoff.owa", StringComparison.OrdinalIgnoreCase))
     {
         if (!Utilities.IsPartnerHostedOnly && !CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).NoFormBasedAuthentication.Enabled)
         {
             FbaModule.InvalidateKeyCache(base.ClientRequest);
         }
         Utility.DeleteFbaAuthCookies(base.ClientRequest, base.ClientResponse, false);
     }
 }
Пример #6
0
 // Token: 0x060005E4 RID: 1508 RVA: 0x00020E08 File Offset: 0x0001F008
 private static void ConfigureSecureProtocols()
 {
     if (CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).EnableTls11.Enabled)
     {
         ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11;
     }
     if (CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).EnableTls12.Enabled)
     {
         ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
     }
 }
Пример #7
0
 // Token: 0x060005CF RID: 1487 RVA: 0x00020554 File Offset: 0x0001E754
 protected override BackEndServer GetE12TargetServer(BackEndServer mailboxServer)
 {
     if (!Utilities.IsPartnerHostedOnly && !CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).NoCrossForestServerLocate.Enabled)
     {
         Uri e12ExternalUrl = HttpProxyBackEndHelper.GetE12ExternalUrl <OwaService>(mailboxServer);
         if (e12ExternalUrl != null)
         {
             throw new HttpException(302, e12ExternalUrl.ToString());
         }
     }
     return(base.GetE12TargetServer(mailboxServer));
 }
Пример #8
0
        // Token: 0x0600023A RID: 570 RVA: 0x0000B164 File Offset: 0x00009364
        private static int GetMailboxServerCacheInMemoryTimeoutValue()
        {
            int    result = 1440;
            string value  = CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).InMemoryMailboxServerCacheTimeoutInMinutes.Value;
            int    num;

            if (!string.IsNullOrEmpty(value) && int.TryParse(value, out num))
            {
                result = num;
            }
            return(result);
        }
Пример #9
0
        // Token: 0x060005D2 RID: 1490 RVA: 0x000205F8 File Offset: 0x0001E7F8
        private string GetCrossPremiseRedirectUrl(string domainName, string externalDirectoryOrgId, string externalEmailAddress)
        {
            NameValueCollection nameValueCollection = new NameValueCollection();
            string value = UrlUtilities.IsConsumerRequestForO365(base.HttpContext) ? OwaProxyRequestHandler.SilentRedirection : OwaProxyRequestHandler.ManualRedirection;

            nameValueCollection.Add("redirectType", value);
            nameValueCollection.Add("extDomain", domainName);
            nameValueCollection.Add("extDirOrgId", externalDirectoryOrgId);
            if (CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).AddExternalEmailAddressToRedirectURL.Enabled)
            {
                nameValueCollection.Add("extEmail", externalEmailAddress);
            }
            return(AspNetHelper.GetCafeErrorPageRedirectUrl(base.HttpContext, nameValueCollection));
        }
Пример #10
0
 // Token: 0x0600050B RID: 1291 RVA: 0x0001BCEC File Offset: 0x00019EEC
 protected override void HandleLogoffRequest()
 {
     if (base.ClientRequest != null && base.ClientResponse != null && base.ClientRequest.Url.AbsolutePath.EndsWith("logoff.aspx", StringComparison.OrdinalIgnoreCase))
     {
         if (!Utilities.IsPartnerHostedOnly && !CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).NoFormBasedAuthentication.Enabled)
         {
             FbaModule.InvalidateKeyCache(base.ClientRequest);
         }
         bool flag = false;
         if (!string.IsNullOrEmpty(base.ClientRequest.UserAgent) && new UserAgent(base.ClientRequest.UserAgent, base.ClientRequest.Cookies).DoesSupportSameSiteNone())
         {
             flag = true;
         }
         Utility.DeleteFbaAuthCookies(base.ClientRequest, base.ClientResponse, flag);
     }
 }
Пример #11
0
        // Token: 0x06000515 RID: 1301 RVA: 0x0001C5A4 File Offset: 0x0001A7A4
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string, Uri>((long)this.GetHashCode(), "[EDiscoveryExportToolProxyRequestHandler::ResolveAnchorMailbox]: Method {0}; Url {1};", base.ClientRequest.HttpMethod, base.ClientRequest.Url);
            }
            string[] array = base.ClientRequest.Url.AbsolutePath.Split(new char[]
            {
                '/'
            }, StringSplitOptions.RemoveEmptyEntries);
            if (((array.Length == 5 && array[4].StartsWith("microsoft.exchange.")) || (array.Length == 6 && array[5].StartsWith("microsoft.exchange."))) && array[2] == "exporttool" && array[3].Contains("."))
            {
                this.serverFqdn = array[3];
            }
            else
            {
                this.serverFqdn = null;
            }
            Match         pathMatch         = EDiscoveryExportToolRequestPathHandler.GetPathMatch(base.ClientRequest);
            bool          exactVersionMatch = false;
            ServerVersion serverVersion;

            if (pathMatch.Success)
            {
                if (RegexUtilities.TryGetServerVersionFromRegexMatch(pathMatch, ref serverVersion))
                {
                    exactVersionMatch = true;
                }
            }
            else
            {
                serverVersion     = new ServerVersion(Server.CurrentExchangeMajorVersion, 0, 0, 0);
                exactVersionMatch = false;
            }
            if (((!string.IsNullOrEmpty(this.serverFqdn)) ? CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).DiscoveryExportToolDownloadRoutingMechanism.Value : string.Empty) == "ServerInfo")
            {
                base.Logger.Set(3, "EDiscoveryExportTool-ServerInfo");
                return(new ServerInfoAnchorMailbox(this.serverFqdn, this));
            }
            if (EDiscoveryExportToolRequestPathHandler.IsEDiscoveryExportToolRequest(base.ClientRequest))
            {
                AnchorMailbox result = new ServerVersionAnchorMailbox <EcpService>(serverVersion, 0, exactVersionMatch, this);
                base.Logger.Set(3, "EDiscoveryExportTool-ServerVersion");
                return(result);
            }
            throw new HttpProxyException(HttpStatusCode.NotFound, 3007, string.Format("Unable to find target server for url: {0}", base.ClientRequest.Url));
        }
Пример #12
0
 // Token: 0x06000461 RID: 1121 RVA: 0x00018920 File Offset: 0x00016B20
 internal static bool TryGetSiteNameFromServerFqdn(string serverFqdn, out string siteName)
 {
     siteName = string.Empty;
     if (string.IsNullOrEmpty(serverFqdn))
     {
         throw new ArgumentNullException("serverFqdn");
     }
     string[] array = serverFqdn.Split(new char[]
     {
         '.'
     });
     if ((Utilities.IsPartnerHostedOnly || CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).SiteNameFromServerFqdnTranslation.Enabled) && array[0].Length > 5)
     {
         siteName = array[0].Substring(0, array[0].Length - 5);
         return(true);
     }
     siteName = array[0];
     return(true);
 }
Пример #13
0
        // Token: 0x060001EA RID: 490 RVA: 0x00009428 File Offset: 0x00007628
        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, 3001, string.Format("{0} does not support down level server proxy.", HttpProxyGlobals.ProtocolType));
            }
            redirectUrl = null;
            if (mailboxServer.Version < Server.E14MinVersion)
            {
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                {
                    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("d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServer", 415);
            Site            site   = currentLegacyServiceTopology.GetSite(mailboxServer.Fqdn, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServer", 416);
            ServiceType     result = this.GetClientAccessServiceInSite <ServiceType>(currentLegacyServiceTopology, anchorMailbox, site, clientAccessType, (ServiceType service) => service.ServerVersionNumber >= Server.E14MinVersion && service.ServerVersionNumber < Server.E15MinVersion, logger);

            if (calculateRedirectUrl && !Utilities.IsPartnerHostedOnly && !CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).NoCrossSiteRedirect.Enabled&& result != null && !string.IsNullOrEmpty(result.ServerFullyQualifiedDomainName) && !HttpProxyGlobals.LocalSite.Member.DistinguishedName.Equals(result.Site.DistinguishedName))
            {
                HttpService httpService = currentLegacyServiceTopology.FindAny <ServiceType>(1, (ServiceType externalService) => externalService != null && externalService.ServerFullyQualifiedDomainName.Equals(result.ServerFullyQualifiedDomainName, StringComparison.OrdinalIgnoreCase), "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServer", 441);
                if (httpService != null)
                {
                    redirectUrl = httpService.Url;
                }
            }
            return(new BackEndServer(result.ServerFullyQualifiedDomainName, result.ServerVersionNumber));
        }
Пример #14
0
 // Token: 0x0600050C RID: 1292 RVA: 0x0001BDA0 File Offset: 0x00019FA0
 protected override AnchorMailbox ResolveAnchorMailbox()
 {
     if (base.State != ProxyRequestHandler.ProxyState.CalculateBackEndSecondRound)
     {
         if (!base.AuthBehavior.IsFullyAuthenticated())
         {
             base.HasPreemptivelyCheckedForRoutingHint = true;
             string liveIdMemberName;
             if (RequestHeaderParser.TryGetAnchorMailboxUpn(base.ClientRequest.Headers, ref liveIdMemberName))
             {
                 if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                 {
                     ExTraceGlobals.VerboseTracer.TraceDebug <int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: From Header Routing UPN Hint, context {1}.", base.TraceContext);
                 }
                 base.Logger.SafeSet(3, "OwaEcpUpn");
                 return(new LiveIdMemberNameAnchorMailbox(liveIdMemberName, null, this));
             }
             AnchorMailbox anchorMailbox = base.CreateAnchorMailboxFromRoutingHint();
             if (anchorMailbox != null)
             {
                 if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                 {
                     ExTraceGlobals.VerboseTracer.TraceDebug <int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: From Header Routing Hint, context {1}.", base.TraceContext);
                 }
                 return(anchorMailbox);
             }
         }
         string text = this.TryGetExplicitLogonNode(0);
         bool   flag;
         if (!string.IsNullOrEmpty(text))
         {
             if (SmtpAddress.IsValidSmtpAddress(text))
             {
                 base.IsExplicitSignOn      = true;
                 base.ExplicitSignOnAddress = text;
                 base.Logger.Set(3, "ExplicitSignOn-SMTP");
                 if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                 {
                     ExTraceGlobals.VerboseTracer.TraceDebug <string, int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: ExplicitSignOn-SMTP. Address {0}, context {1}.", text, base.TraceContext);
                 }
                 return(new SmtpAnchorMailbox(text, this));
             }
             if ((Utilities.IsPartnerHostedOnly || CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).SyndicatedAdmin.Enabled) && text.StartsWith("@"))
             {
                 this.isSyndicatedAdmin = true;
                 text = text.Substring(1);
                 if (SmtpAddress.IsValidDomain(text))
                 {
                     string text2 = this.TryGetExplicitLogonNode(1);
                     if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                     {
                         ExTraceGlobals.VerboseTracer.TraceDebug <string, string, int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: SyndAdmin, domain {0}, SMTP {1}, context {2}.", text, text2, base.TraceContext);
                     }
                     if (!string.IsNullOrEmpty(text2) && SmtpAddress.IsValidSmtpAddress(text2))
                     {
                         base.IsExplicitSignOn      = true;
                         base.ExplicitSignOnAddress = text2;
                         base.Logger.Set(3, "SyndAdmin-SMTP");
                         return(new SmtpAnchorMailbox(text2, this));
                     }
                     base.Logger.Set(3, "SyndAdmin-Domain");
                     return(new DomainAnchorMailbox(text, this));
                 }
             }
         }
         else if (!Utilities.IsPartnerHostedOnly && !GlobalConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MultiTenancy.Enabled)
         {
             string text3 = this.TryGetBackendParameter("TargetServer", out flag);
             if (!string.IsNullOrEmpty(text3))
             {
                 base.Logger.Set(3, "TargetServer" + (flag ? "-UrlQuery" : "-Cookie"));
                 if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                 {
                     ExTraceGlobals.VerboseTracer.TraceDebug <string, string, int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: On-Premise, TargetServer parameter {0}, from {1}, context {2}.", text3, flag ? "url query" : "cookie", base.TraceContext);
                 }
                 return(new ServerInfoAnchorMailbox(text3, this));
             }
         }
         string text4 = this.TryGetBackendParameter("ExchClientVer", out flag);
         if (!string.IsNullOrEmpty(text4))
         {
             string text5 = Utilities.NormalizeExchClientVer(text4);
             base.Logger.Set(3, "ExchClientVer" + (flag ? "-UrlQuery" : "-Cookie"));
             if (!Utilities.IsPartnerHostedOnly && !GlobalConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MultiTenancy.Enabled)
             {
                 if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                 {
                     ExTraceGlobals.VerboseTracer.TraceDebug <string, string, int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: On-Premise, Version parameter {0}, from {1}, context {2}.", text4, flag ? "url query" : "cookie", base.TraceContext);
                 }
                 return(base.GetServerVersionAnchorMailbox(text5));
             }
             string text6 = (string)base.HttpContext.Items["AuthenticatedUserOrganization"];
             if (!string.IsNullOrEmpty(text6))
             {
                 if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                 {
                     ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: On-Cloud, Version parameter {0}, from {1}, domain {2}, context {3}.", new object[]
                     {
                         text5,
                         flag ? "url query" : "cookie",
                         text6,
                         base.TraceContext
                     });
                 }
                 return(VersionedDomainAnchorMailbox.GetAnchorMailbox(text6, text5, this));
             }
             if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
             {
                 ExTraceGlobals.VerboseTracer.TraceDebug <int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: AuthenticatedUserOrganization is null. Context {0}.", base.TraceContext);
             }
         }
     }
     if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
     {
         ExTraceGlobals.VerboseTracer.TraceDebug <string, int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: {0}, context {1}, call base method to do regular anchor mailbox calculation.", (base.State == ProxyRequestHandler.ProxyState.CalculateBackEndSecondRound) ? "Second round" : "Nothing special", base.TraceContext);
     }
     return(base.ResolveAnchorMailbox());
 }
        // Token: 0x0600015A RID: 346 RVA: 0x00007538 File Offset: 0x00005738
        public override BackEndServer TryDirectBackEndCalculation()
        {
            if (this.ServerVersion.Major == 15 && !this.ExactVersionMatch)
            {
                BackEndServer backEndServer = LocalSiteMailboxServerCache.Instance.TryGetRandomE15Server(base.RequestContext);
                if (backEndServer != null && new ServerVersion(backEndServer.Version).Minor >= this.ServerVersion.Minor)
                {
                    return(backEndServer);
                }
            }
            if (GlobalConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MultiTenancy.Enabled&& CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).ServersCache.Enabled)
            {
                try
                {
                    MiniServer miniServer;
                    if (this.ExactVersionMatch)
                    {
                        miniServer = ServersCache.GetAnyBackEndServerWithExactVersion(this.ServerVersion.ToInt());
                    }
                    else
                    {
                        miniServer = ServersCache.GetAnyBackEndServerWithMinVersion(this.ServerVersion.ToInt());
                    }
                    return(new BackEndServer(miniServer.Fqdn, miniServer.VersionNumber));
                }
                catch (ServerHasNotBeenFoundException)
                {
                    return(base.CheckForNullAndThrowIfApplicable <BackEndServer>(null));
                }
            }
            BackEndServer result;

            try
            {
                result = HttpProxyBackEndHelper.GetAnyBackEndServerForVersion <ServiceType>(this.ServerVersion, this.ExactVersionMatch, this.ClientAccessType, false);
            }
            catch (ServerNotFoundException)
            {
                result = base.CheckForNullAndThrowIfApplicable <BackEndServer>(null);
            }
            return(result);
        }
Пример #16
0
 // Token: 0x060004F3 RID: 1267 RVA: 0x0001B76E File Offset: 0x0001996E
 private bool IsBackEndCookieAndHeaderFlightEnabled()
 {
     return(CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).E4eBackendCookieHint.Enabled);
 }
Пример #17
0
        // Token: 0x060005CA RID: 1482 RVA: 0x000200D0 File Offset: 0x0001E2D0
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            if (base.AuthBehavior.IsFullyAuthenticated())
            {
                return(this.LegacyResolveAnchorMailbox());
            }
            base.HasPreemptivelyCheckedForRoutingHint = true;
            string        liveIdMemberName;
            AnchorMailbox anchorMailbox;

            if (!RequestHeaderParser.TryGetAnchorMailboxUpn(base.ClientRequest.Headers, ref liveIdMemberName))
            {
                anchorMailbox = base.CreateAnchorMailboxFromRoutingHint();
            }
            else
            {
                base.Logger.SafeSet(3, "OwaEcpUpn");
                anchorMailbox = new LiveIdMemberNameAnchorMailbox(liveIdMemberName, null, this);
            }
            string text;

            RequestHeaderParser.TryGetExplicitLogonSmtp(base.ClientRequest.Headers, ref text);
            if (anchorMailbox == null)
            {
                if (base.UseRoutingHintForAnchorMailbox)
                {
                    if (!string.IsNullOrEmpty(text) && SmtpAddress.IsValidSmtpAddress(text))
                    {
                        base.IsExplicitSignOn      = true;
                        base.ExplicitSignOnAddress = text;
                        base.Logger.Set(3, "ExplicitLogon-SMTP-Header");
                        anchorMailbox = new SmtpAnchorMailbox(text, this);
                    }
                    else
                    {
                        text = this.TryGetExplicitLogonNode(0);
                        if (!string.IsNullOrEmpty(text))
                        {
                            if (SmtpAddress.IsValidSmtpAddress(text))
                            {
                                base.IsExplicitSignOn      = true;
                                base.ExplicitSignOnAddress = text;
                                base.Logger.Set(3, "ExplicitLogon-SMTP");
                                anchorMailbox = new SmtpAnchorMailbox(text, this);
                            }
                            else if ((Utilities.IsPartnerHostedOnly || CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).ExplicitDomain.Enabled) && SmtpAddress.IsValidDomain(text))
                            {
                                text = this.TryGetExplicitLogonNode(1);
                                if (text != null)
                                {
                                    base.IsExplicitSignOn      = true;
                                    base.ExplicitSignOnAddress = text;
                                    base.Logger.Set(3, "ExplicitLogon-SMTP");
                                    anchorMailbox = new SmtpAnchorMailbox(text, this);
                                }
                            }
                        }
                    }
                }
                if (anchorMailbox == null)
                {
                    anchorMailbox = base.ResolveAnchorMailbox();
                }
                else
                {
                    base.IsAnchorMailboxFromRoutingHint         = true;
                    this.originalAnchorMailboxFromExplicitLogon = anchorMailbox;
                }
            }
            else if (!string.IsNullOrWhiteSpace(text))
            {
                if (!string.Equals(anchorMailbox.SourceObject.ToString(), text, StringComparison.InvariantCultureIgnoreCase))
                {
                    RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(base.Logger, "ExplicitLogonMismatch", string.Format("{0}~{1}", anchorMailbox.SourceObject, text));
                }
                this.originalAnchorMailboxFromExplicitLogon = anchorMailbox;
            }
            UserBasedAnchorMailbox userBasedAnchorMailbox = anchorMailbox as UserBasedAnchorMailbox;

            if (userBasedAnchorMailbox != null)
            {
                userBasedAnchorMailbox.MissingDatabaseHandler = new Func <ADRawEntry, ADObjectId>(this.ResolveMailboxDatabase);
            }
            return(anchorMailbox);
        }
Пример #18
0
        // Token: 0x060005D4 RID: 1492 RVA: 0x0002073C File Offset: 0x0001E93C
        private AnchorMailbox LegacyResolveAnchorMailbox()
        {
            AnchorMailbox anchorMailbox = null;

            if (base.UseRoutingHintForAnchorMailbox)
            {
                string text;
                if (RequestHeaderParser.TryGetExplicitLogonSmtp(base.ClientRequest.Headers, ref text))
                {
                    base.IsExplicitSignOn      = true;
                    base.ExplicitSignOnAddress = text;
                    base.Logger.Set(3, "ExplicitLogon-SMTP-Header");
                    anchorMailbox = new SmtpAnchorMailbox(text, this);
                }
                else
                {
                    text = this.TryGetExplicitLogonNode(0);
                    if (!string.IsNullOrEmpty(text))
                    {
                        if (SmtpAddress.IsValidSmtpAddress(text))
                        {
                            base.IsExplicitSignOn      = true;
                            base.ExplicitSignOnAddress = text;
                            base.Logger.Set(3, "ExplicitLogon-SMTP");
                            anchorMailbox = new SmtpAnchorMailbox(text, this);
                        }
                        else if ((Utilities.IsPartnerHostedOnly || CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).ExplicitDomain.Enabled) && SmtpAddress.IsValidDomain(text))
                        {
                            string domain = text;
                            text = this.TryGetExplicitLogonNode(1);
                            if (text == null)
                            {
                                base.Logger.Set(3, "ExplicitLogon-Domain");
                                anchorMailbox = new DomainAnchorMailbox(domain, this);
                            }
                            else if (SmtpAddress.IsValidSmtpAddress(text))
                            {
                                base.IsExplicitSignOn      = true;
                                base.ExplicitSignOnAddress = text;
                                base.Logger.Set(3, "ExplicitLogon-SMTP");
                                anchorMailbox = new SmtpAnchorMailbox(text, this);
                            }
                        }
                    }
                }
            }
            if (anchorMailbox == null)
            {
                anchorMailbox = base.ResolveAnchorMailbox();
            }
            else
            {
                base.IsAnchorMailboxFromRoutingHint         = true;
                this.originalAnchorMailboxFromExplicitLogon = anchorMailbox;
            }
            UserBasedAnchorMailbox userBasedAnchorMailbox = anchorMailbox as UserBasedAnchorMailbox;

            if (userBasedAnchorMailbox != null)
            {
                userBasedAnchorMailbox.MissingDatabaseHandler = new Func <ADRawEntry, ADObjectId>(this.ResolveMailboxDatabase);
            }
            return(anchorMailbox);
        }
        // Token: 0x060006F1 RID: 1777 RVA: 0x00028B18 File Offset: 0x00026D18
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(base.HttpContext.Request.Url.Query.Replace(';', '&'));
            string text = nameValueCollection["TargetServer"];

            if (!string.IsNullOrEmpty(text))
            {
                base.Logger.Set(3, "TargetServer");
                return(new ServerInfoAnchorMailbox(text, this));
            }
            if (CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).UseMailboxHintForRPSRouting.Enabled)
            {
                string text2 = nameValueCollection["Email"];
                if (!string.IsNullOrEmpty(text2))
                {
                    if (!SmtpAddress.IsValidSmtpAddress(text2))
                    {
                        throw new HttpProxyException(HttpStatusCode.NotFound, 3002, string.Format("Invalid email address {0} for routing hint.", text2));
                    }
                    base.Logger.Set(3, "Email");
                    return(new SmtpAnchorMailbox(text2, this));
                }
            }
            string text3 = nameValueCollection["ExchClientVer"];

            if (!string.IsNullOrWhiteSpace(text3))
            {
                text3 = Utilities.NormalizeExchClientVer(text3);
            }
            if (CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).UseExchClientVerInRPS.Enabled)
            {
                base.Logger.Set(3, "ExchClientVer");
                return(base.GetServerVersionAnchorMailbox(text3));
            }
            bool   flag;
            string text4;
            string routingBasedOrganization = this.GetRoutingBasedOrganization(nameValueCollection, out flag, out text4);

            if (!this.isSyndicatedAdmin && !string.IsNullOrWhiteSpace(text3))
            {
                if (!string.IsNullOrWhiteSpace(routingBasedOrganization))
                {
                    if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                    {
                        ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[RemotePowerShellProxyRequestHandler::ResolveAnchorMailbox]: Datacenter, Version parameter {0}, from {1}, organization {2}, context {3}.", new object[]
                        {
                            text3,
                            text4,
                            routingBasedOrganization,
                            base.TraceContext
                        });
                    }
                    base.Logger.Set(3, text4 + "-" + text3);
                    return(VersionedDomainAnchorMailbox.GetAnchorMailbox(routingBasedOrganization, text3, this));
                }
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug <string, int>((long)this.GetHashCode(), "[RemotePowerShellProxyRequestHandler::ResolveAnchorMailbox]: ExchClientVer {0} is specified, but User-Org/Org anization/DelegatedOrg is null. Go with normal routing. Context {2}.", text3, base.TraceContext);
                }
            }
            string text5 = nameValueCollection["DelegatedUser"];

            if (!string.IsNullOrEmpty(text5))
            {
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug <string, int>((long)this.GetHashCode(), "[RemotePowerShellProxyRequestHandler::ResolveAnchorMailbox]: User hint {0}, context {1}.", text5, base.TraceContext);
                }
                if (!string.IsNullOrEmpty(text5) && SmtpAddress.IsValidSmtpAddress(text5))
                {
                    base.Logger.Set(3, "DelegatedUser-SMTP-UrlQuery");
                    return(new SmtpAnchorMailbox(text5, this));
                }
            }
            if (flag)
            {
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug <string, string, int>((long)this.GetHashCode(), "[RemotePowerShellProxyRequestHandler::ResolveAnchorMailbox]: Organization-based. Organization {0} from {1}, context {2}.", routingBasedOrganization, text4, base.TraceContext);
                }
                DomainAnchorMailbox domainAnchorMailbox = new DomainAnchorMailbox(routingBasedOrganization, this);
                if (this.isSyndicatedAdmin && !this.IsSecurityTokenPresent())
                {
                    ExchangeObjectVersion exchangeObjectVersion = domainAnchorMailbox.GetADRawEntry()[OrganizationConfigSchema.AdminDisplayVersion] as ExchangeObjectVersion;
                    if (exchangeObjectVersion.ExchangeBuild.Major < ExchangeObjectVersion.Exchange2012.ExchangeBuild.Major)
                    {
                        if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                        {
                            ExTraceGlobals.VerboseTracer.TraceDebug <ExchangeObjectVersion>((long)this.GetHashCode(), "[RemotePowerShellProxyRequestHandler::ResolveAnchorMailbox] Syndicated Admin. Target tenant is in E14 forest. Let backend generate security token and do the redirection. ExchangeVersion: {0}", exchangeObjectVersion);
                        }
                        this.isSyndicatedAdminManageDownLevelTarget = true;
                        base.Logger.AppendGenericInfo("SyndicatedAdminTargetTenantDownLevel", true);
                        return(base.ResolveAnchorMailbox());
                    }
                }
                base.Logger.Set(3, text4);
                return(domainAnchorMailbox);
            }
            return(base.ResolveAnchorMailbox());
        }
Пример #20
0
        // Token: 0x060001A2 RID: 418 RVA: 0x00008724 File Offset: 0x00006924
        public override BackEndServer TryDirectBackEndCalculation()
        {
            BackEndServer backEndServer = LocalSiteMailboxServerCache.Instance.TryGetRandomE15Server(base.RequestContext);

            if (backEndServer != null)
            {
                return(backEndServer);
            }
            if (GlobalConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MultiTenancy.Enabled&& CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).ServersCache.Enabled)
            {
                try
                {
                    MiniServer anyBackEndServerFromLocalSite = ServersCache.GetAnyBackEndServerFromLocalSite(Server.E15MinVersion, false);
                    return(new BackEndServer(anyBackEndServerFromLocalSite.Fqdn, anyBackEndServerFromLocalSite.VersionNumber));
                }
                catch (ServerHasNotBeenFoundException)
                {
                    return(base.CheckForNullAndThrowIfApplicable <BackEndServer>(null));
                }
            }
            return(HttpProxyBackEndHelper.GetAnyBackEndServerForVersion <WebServicesService>(new ServerVersion(Server.E15MinVersion), false, 2, true));
        }