// Token: 0x060005B4 RID: 1460 RVA: 0x0001F9D0 File Offset: 0x0001DBD0
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string, Uri>((long)this.GetHashCode(), "[OwaExtensibilityProxyRequestHandler::ResolveAnchorMailbox]: Method {0}; Url {1};", base.ClientRequest.HttpMethod, base.ClientRequest.Url);
            }
            Match match = OwaExtensibilityProxyRequestHandler.ExtPathRegex.Match(base.ClientRequest.RawUrl);

            if (!match.Success)
            {
                match = OwaExtensibilityProxyRequestHandler.ScriptsPathRegex.Match(base.ClientRequest.RawUrl);
                if (!match.Success)
                {
                    match = OwaExtensibilityProxyRequestHandler.StylesPathRegex.Match(base.ClientRequest.RawUrl);
                }
            }
            Guid   guid;
            string text;

            if (match.Success && RegexUtilities.TryGetMailboxGuidAddressFromRegexMatch(match, ref guid, ref text))
            {
                this.routingHint = string.Format("{0}@{1}", guid, text);
                AnchorMailbox result = new MailboxGuidAnchorMailbox(guid, text, this);
                base.Logger.Set(3, "OwaExtension-MailboxGuidWithDomain");
                return(result);
            }
            throw new HttpProxyException(HttpStatusCode.NotFound, 3007, string.Format("Unable to find target server for url: {0}", base.ClientRequest.Url));
        }
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            AnonymousPublishingUrl anonymousPublishingUrl = new AnonymousPublishingUrl(base.ClientRequest.Url);

            if (anonymousPublishingUrl.ParameterSegments.Length > 0)
            {
                string text  = anonymousPublishingUrl.ParameterSegments[0];
                Match  match = RegexUtilities.TryMatch(Constants.GuidAtDomainRegex, text, base.Logger);
                if (match != null && match.Success)
                {
                    Guid   mailboxGuid = new Guid(match.Result("${mailboxguid}"));
                    string text2       = match.Result("${domain}");
                    string value       = string.Format("AnonymousPublishingUrl-MailboxGuid{0}", string.IsNullOrEmpty(text2) ? string.Empty : "WithDomainAndSmtpFallback");
                    base.Logger.Set(HttpProxyMetadata.RoutingHint, value);
                    MailboxGuidAnchorMailbox mailboxGuidAnchorMailbox = new MailboxGuidAnchorMailbox(mailboxGuid, text2, this);
                    if (!string.IsNullOrEmpty(text2))
                    {
                        mailboxGuidAnchorMailbox.FallbackSmtp = text;
                    }
                    return(mailboxGuidAnchorMailbox);
                }
                match = RegexUtilities.TryMatch(Constants.AddressRegex, text, base.Logger);
                if (match != null && match.Success)
                {
                    string text3 = match.Result("${address}");
                    if (!string.IsNullOrEmpty(text3) && SmtpAddress.IsValidSmtpAddress(text3))
                    {
                        base.Logger.Set(HttpProxyMetadata.RoutingHint, "AnonymousPublishingUrl-SMTP");
                        return(new SmtpAnchorMailbox(text3, this));
                    }
                }
            }
            return(base.ResolveAnchorMailbox());
        }
示例#3
0
        // Token: 0x060000E7 RID: 231 RVA: 0x00005928 File Offset: 0x00003B28
        public static bool TryCreateFromMailboxGuid(IRequestContext requestContext, string anchorMailboxAddress, out AnchorMailbox anchorMailbox)
        {
            anchorMailbox = null;
            Guid   mailboxGuid;
            string domain;

            if (RequestHeaderParser.TryGetMailboxGuid(anchorMailboxAddress, ref mailboxGuid, ref domain))
            {
                requestContext.Logger.SafeSet(3, "URL-MailboxGuidWithDomain");
                anchorMailbox = new MailboxGuidAnchorMailbox(mailboxGuid, domain, requestContext);
                return(true);
            }
            return(false);
        }
示例#4
0
        public static bool TryCreateFromMailboxGuid(IRequestContext requestContext, string anchorMailboxAddress, out AnchorMailbox anchorMailbox)
        {
            anchorMailbox = null;
            Guid   mailboxGuid;
            string domain;

            if (AnchorMailboxFactory.TryGetMailboxGuid(anchorMailboxAddress, out mailboxGuid, out domain, requestContext))
            {
                requestContext.Logger.SafeSet(HttpProxyMetadata.RoutingHint, "URL-MailboxGuidWithDomain");
                anchorMailbox = new MailboxGuidAnchorMailbox(mailboxGuid, domain, requestContext);
                return(true);
            }
            return(false);
        }
        // Token: 0x0600049C RID: 1180 RVA: 0x0001973C File Offset: 0x0001793C
        private bool TryMatchByGuidAtDomain(AnonymousPublishingUrl publishingUrl, out AnchorMailbox anchorMailbox)
        {
            anchorMailbox = null;
            string text   = publishingUrl.ParameterSegments[0];
            Guid   empty  = Guid.Empty;
            string empty2 = string.Empty;

            if (RequestHeaderParser.TryGetMailboxGuid(text, ref empty, ref empty2))
            {
                string text2 = string.Format("AnonymousPublishingUrl-MailboxGuid{0}", string.IsNullOrEmpty(empty2) ? string.Empty : "WithDomainAndSmtpFallback");
                base.Logger.Set(3, text2);
                MailboxGuidAnchorMailbox mailboxGuidAnchorMailbox = new MailboxGuidAnchorMailbox(empty, empty2, this);
                if (!string.IsNullOrEmpty(empty2))
                {
                    mailboxGuidAnchorMailbox.FallbackSmtp = text;
                }
                anchorMailbox = mailboxGuidAnchorMailbox;
            }
            return(anchorMailbox != null);
        }
示例#6
0
        // Token: 0x060000E8 RID: 232 RVA: 0x00005968 File Offset: 0x00003B68
        public static ArchiveSupportedAnchorMailbox ParseAnchorMailboxFromSmtp(IRequestContext requestContext, string smtpAddress, string source, bool failOnDomainNotFound)
        {
            Guid   empty  = Guid.Empty;
            string empty2 = string.Empty;

            if (RequestHeaderParser.TryGetMailboxGuid(smtpAddress, ref empty, ref empty2))
            {
                string value = string.Format("{0}-MailboxGuid{1}", source, string.IsNullOrEmpty(empty2) ? string.Empty : "WithDomainAndSmtpFallback");
                requestContext.Logger.SafeSet(3, value);
                MailboxGuidAnchorMailbox mailboxGuidAnchorMailbox = new MailboxGuidAnchorMailbox(empty, empty2, requestContext);
                if (!string.IsNullOrEmpty(empty2))
                {
                    mailboxGuidAnchorMailbox.FallbackSmtp = smtpAddress;
                }
                return(mailboxGuidAnchorMailbox);
            }
            requestContext.Logger.SafeSet(3, string.Format("{0}-SMTP", source));
            return(new SmtpAnchorMailbox(smtpAddress, requestContext)
            {
                FailOnDomainNotFound = failOnDomainNotFound
            });
        }
示例#7
0
        // Token: 0x060000E6 RID: 230 RVA: 0x000056D4 File Offset: 0x000038D4
        public static AnchorMailbox TryCreateFromRoutingHint(IRequestContext requestContext, bool tryTargetServerRoutingHint)
        {
            if (requestContext == null)
            {
                throw new ArgumentNullException("requestContext");
            }
            string fqdn;

            if (tryTargetServerRoutingHint && RequestHeaderParser.TryGetTargetServer(requestContext.HttpContext.Request.Headers, ref fqdn))
            {
                requestContext.Logger.Set(3, "TargetServerHeader");
                return(new ServerInfoAnchorMailbox(fqdn, requestContext));
            }
            string text;

            if (!RequestHeaderParser.TryGetAnchorMailbox(requestContext.HttpContext.Request.Headers, ref text))
            {
                return(null);
            }
            Match match = RegexUtilities.TryMatch(Constants.SidRegex, text);

            if (match != null && match.Success)
            {
                string text2 = RegexUtilities.ParseIdentifier(match, "${sid}");
                if (!string.IsNullOrEmpty(text2))
                {
                    SecurityIdentifier securityIdentifier = null;
                    try
                    {
                        securityIdentifier = new SecurityIdentifier(text2);
                    }
                    catch (ArgumentException ex)
                    {
                        requestContext.Logger.AppendGenericError("Ignored Exception", ex.ToString());
                    }
                    catch (SystemException ex2)
                    {
                        requestContext.Logger.AppendGenericError("Ignored Exception", ex2.ToString());
                    }
                    if (securityIdentifier != null)
                    {
                        requestContext.Logger.SafeSet(3, "AnchorMailboxHeader-SID");
                        return(new SidAnchorMailbox(securityIdentifier, requestContext));
                    }
                }
            }
            Guid   mailboxGuid;
            string text3;

            if (RequestHeaderParser.TryGetMailboxGuid(text, ref mailboxGuid, ref text3))
            {
                string value = string.Format("AnchorMailboxHeader-MailboxGuid{0}", string.IsNullOrEmpty(text3) ? string.Empty : "WithDomain");
                requestContext.Logger.SafeSet(3, value);
                MailboxGuidAnchorMailbox mailboxGuidAnchorMailbox = new MailboxGuidAnchorMailbox(mailboxGuid, text3, requestContext);
                if (!string.IsNullOrEmpty(text3))
                {
                    mailboxGuidAnchorMailbox.FallbackSmtp = text;
                }
                return(mailboxGuidAnchorMailbox);
            }
            if (PuidAnchorMailbox.IsEnabled)
            {
                NetID netID;
                Guid  tenantGuid;
                if (RequestHeaderParser.TryGetNetIdAndTenantGuid(text, ref netID, ref tenantGuid))
                {
                    requestContext.Logger.Set(3, "AnchorMailboxHeader-PuidAndTenantGuid");
                    return(new PuidAnchorMailbox(netID.ToString(), tenantGuid, requestContext, text));
                }
                string text4;
                if (RequestHeaderParser.TryGetNetIdAndDomain(text, ref netID, ref text4))
                {
                    if (string.IsNullOrEmpty(text4))
                    {
                        requestContext.Logger.Set(3, "AnchorMailboxHeader-Puid");
                        return(new PuidAnchorMailbox(netID.ToString(), requestContext, text));
                    }
                    requestContext.Logger.Set(3, "AnchorMailboxHeader-PuidAndDomain");
                    return(new PuidAnchorMailbox(netID.ToString(), text4, requestContext, text));
                }
            }
            if (SmtpAddress.IsValidSmtpAddress(text))
            {
                requestContext.Logger.Set(3, "AnchorMailboxHeader-SMTP");
                return(new SmtpAnchorMailbox(text, requestContext));
            }
            return(null);
        }
        // Token: 0x0600070D RID: 1805 RVA: 0x000296EC File Offset: 0x000278EC
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            UriBuilder uriBuilder = new UriBuilder(base.ClientRequest.Url);

            if (string.IsNullOrEmpty(base.ClientRequest.Url.Query))
            {
                throw new HttpProxyException(HttpStatusCode.NotFound, 3001, "No proxy destination is specified!");
            }
            RpcHttpQueryString rpcHttpQueryString = new RpcHttpQueryString(uriBuilder.Query);

            this.rpcServerTarget = rpcHttpQueryString.RcaServer;
            if (SmtpAddress.IsValidSmtpAddress(this.rpcServerTarget))
            {
                string text;
                HttpContextItemParser.TryGetLiveIdMemberName(base.HttpContext.Items, ref text);
                Guid   guid;
                string domain;
                string text2;
                if (RequestQueryStringParser.TryGetMailboxGuid(this.rpcServerTarget, text, ref guid, ref domain, ref text2))
                {
                    MailboxGuidAnchorMailbox result;
                    if (!string.IsNullOrEmpty(text2))
                    {
                        this.rpcServerTarget = ExchangeRpcClientAccess.CreatePersonalizedServer(guid, text2);
                        base.Logger.AppendString(3, "MailboxGuidWithDomain-ChangedToUserDomain");
                        result = new MailboxGuidAnchorMailbox(guid, text2, this);
                    }
                    else
                    {
                        base.Logger.AppendString(3, "MailboxGuidWithDomain");
                        result = new MailboxGuidAnchorMailbox(guid, domain, this);
                    }
                    this.updateRpcServer = true;
                    return(result);
                }
                return(this.ResolveToDefaultAnchorMailbox(this.rpcServerTarget, "InvalidFormat"));
            }
            else
            {
                ProxyDestination proxyDestination;
                if (RpcHttpProxyRules.Instance.TryGetProxyDestination(this.rpcServerTarget, out proxyDestination))
                {
                    string text3 = proxyDestination.GetHostName(this.GetKeyForCasAffinity());
                    if (proxyDestination.IsDynamicTarget)
                    {
                        try
                        {
                            text3 = DownLevelServerManager.Instance.GetDownLevelClientAccessServerWithPreferredServer <RpcHttpService>(new ServerInfoAnchorMailbox(text3, this), text3, 1, base.Logger, proxyDestination.Version).Fqdn;
                        }
                        catch (NoAvailableDownLevelBackEndException)
                        {
                            throw new HttpProxyException(HttpStatusCode.NotFound, 3001, string.Format("Cannot find a healthy E12 or E14 CAS to proxy to: {0}", this.rpcServerTarget));
                        }
                    }
                    uriBuilder.Host   = text3;
                    uriBuilder.Port   = proxyDestination.Port;
                    uriBuilder.Scheme = Uri.UriSchemeHttps;
                    base.Logger.Set(3, "RpcHttpProxyRules");
                    this.updateRpcServer = false;
                    return(new UrlAnchorMailbox(uriBuilder.Uri, this));
                }
                return(this.ResolveToDefaultAnchorMailbox(this.rpcServerTarget, "UnknownServerName"));
            }
        }
示例#9
0
        public static AnchorMailbox TryCreateFromRoutingHint(IRequestContext requestContext, bool tryTargetServerRoutingHint)
        {
            if (requestContext == null)
            {
                throw new ArgumentNullException("requestContext");
            }
            string text = requestContext.HttpContext.Request.Headers[WellKnownHeader.XTargetServer];

            if (!string.IsNullOrEmpty(text) && tryTargetServerRoutingHint)
            {
                requestContext.Logger.Set(HttpProxyMetadata.RoutingHint, "TargetServerHeader");
                return(new ServerInfoAnchorMailbox(text, requestContext));
            }
            string text2 = requestContext.HttpContext.Request.Headers[Constants.AnchorMailboxHeaderName];

            if (string.IsNullOrEmpty(text2))
            {
                return(null);
            }
            Match match = RegexUtilities.TryMatch(Constants.SidRegex, text2, requestContext.Logger);

            if (match != null && match.Success)
            {
                string text3 = RegexUtilities.ParseIdentifier(match, "${sid}", requestContext.Logger);
                if (!string.IsNullOrEmpty(text3))
                {
                    SecurityIdentifier securityIdentifier = null;
                    try
                    {
                        securityIdentifier = new SecurityIdentifier(text3);
                    }
                    catch (ArgumentException ex)
                    {
                        requestContext.Logger.AppendGenericError("Ignored Exception", ex.ToString());
                    }
                    catch (SystemException ex2)
                    {
                        requestContext.Logger.AppendGenericError("Ignored Exception", ex2.ToString());
                    }
                    if (securityIdentifier != null)
                    {
                        requestContext.Logger.SafeSet(HttpProxyMetadata.RoutingHint, "AnchorMailboxHeader-SID");
                        return(new SidAnchorMailbox(securityIdentifier, requestContext));
                    }
                }
            }
            match = RegexUtilities.TryMatch(Constants.GuidAtDomainRegex, text2, requestContext.Logger);
            if (match != null && match.Success)
            {
                string text4 = RegexUtilities.ParseIdentifier(match, "${mailboxguid}", requestContext.Logger);
                if (!string.IsNullOrEmpty(text4))
                {
                    Guid   mailboxGuid = new Guid(text4);
                    string text5       = RegexUtilities.ParseIdentifier(match, "${domain}", requestContext.Logger);
                    string value       = string.Format("AnchorMailboxHeader-MailboxGuid{0}", string.IsNullOrEmpty(text5) ? string.Empty : "WithDomain");
                    requestContext.Logger.SafeSet(HttpProxyMetadata.RoutingHint, value);
                    MailboxGuidAnchorMailbox mailboxGuidAnchorMailbox = new MailboxGuidAnchorMailbox(mailboxGuid, text5, requestContext);
                    if (!string.IsNullOrEmpty(text5))
                    {
                        mailboxGuidAnchorMailbox.FallbackSmtp = text2;
                    }
                    return(mailboxGuidAnchorMailbox);
                }
            }
            if (SmtpAddress.IsValidSmtpAddress(text2))
            {
                requestContext.Logger.Set(HttpProxyMetadata.RoutingHint, "AnchorMailboxHeader-SMTP");
                return(new SmtpAnchorMailbox(text2, requestContext));
            }
            return(null);
        }