Example #1
0
        private static IRoutingKey[] FindByAnchorMailbox(string anchorMailbox, IAddressFinderDiagnostics diagnostics)
        {
            if (string.IsNullOrEmpty(anchorMailbox))
            {
                return(AddressFinderHelper.EmptyRoutingKeyArray);
            }
            Match match = Constants.GuidAtDomainRegex.Match(anchorMailbox);

            if (match != null && match.Success)
            {
                string text = match.Result("${mailboxguid}");
                if (!string.IsNullOrEmpty(text))
                {
                    Guid        mailboxGuid = new Guid(text);
                    string      text2       = match.Result("${domain}");
                    IRoutingKey routingKey  = new MailboxGuidRoutingKey(mailboxGuid, text2);
                    diagnostics.AddRoutingkey(routingKey, "MailboxGuidInAnchorMailbox");
                    if (string.IsNullOrEmpty(text2))
                    {
                        return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[]
                        {
                            routingKey
                        }));
                    }
                    if (SmtpAddress.IsValidSmtpAddress(anchorMailbox))
                    {
                        IRoutingKey routingKey2 = new SmtpRoutingKey(new SmtpAddress(anchorMailbox));
                        diagnostics.AddRoutingkey(routingKey2, "FallbackSmtpAddressInAnchorMailbox");
                        return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[]
                        {
                            routingKey,
                            routingKey2
                        }));
                    }
                    ExTraceGlobals.VerboseTracer.TraceDebug <string>(0L, "[RoutingHintAddressFinder::FindByAnchorMailbox]: Malformed smtp address in X-AnchorMailbox {0}.", anchorMailbox);
                }
            }
            if (SmtpAddress.IsValidSmtpAddress(anchorMailbox))
            {
                IRoutingKey routingKey3 = new SmtpRoutingKey(new SmtpAddress(anchorMailbox));
                diagnostics.AddRoutingkey(routingKey3, "SmtpAddressInAnchorMailbox");
                return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[]
                {
                    routingKey3
                }));
            }
            ExTraceGlobals.VerboseTracer.TraceDebug <string>(0L, "[RoutingHintAddressFinder::FindByAnchorMailbox]: Invalid smtp address in X-AnchorMailbox {0}.", anchorMailbox);
            return(AddressFinderHelper.EmptyRoutingKeyArray);
        }
Example #2
0
        IRoutingKey[] IAddressFinder.Find(AddressFinderSource source, IAddressFinderDiagnostics diagnostics)
        {
            AddressFinderHelper.ThrowIfNull(source, diagnostics);
            string text = source.Items["WLID-MemberName"] as string;

            if (string.IsNullOrEmpty(text))
            {
                return(AddressFinderHelper.EmptyRoutingKeyArray);
            }
            if (!SmtpAddress.IsValidSmtpAddress(text))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "[LogonUserAddressFinder::Find]: Malformed memberName {0}.", text);
                return(AddressFinderHelper.EmptyRoutingKeyArray);
            }
            string text2 = source.Items["WLID-OrganizationContext"] as string;

            if (!string.IsNullOrEmpty(text2) && !SmtpAddress.IsValidDomain(text2))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "[LogonUserAddressFinder::Find]: Malformed organizationContext {0}.", text2);
                text2 = null;
            }
            IRoutingKey routingKey = new LiveIdMemberNameRoutingKey(new SmtpAddress(text), text2);

            diagnostics.AddRoutingkey(routingKey, "LogonUser");
            return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[]
            {
                routingKey
            }));
        }
Example #3
0
        private static IRoutingKey FindByMailboxId(string mailboxId, IAddressFinderDiagnostics diagnostics)
        {
            if (string.IsNullOrEmpty(mailboxId))
            {
                return(null);
            }
            if (!SmtpAddress.IsValidSmtpAddress(mailboxId))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string>(0L, "[MapiAddressFinder::FindByMailboxId]: Malformed mailboxId {0}.", mailboxId);
                return(null);
            }
            Guid   guid         = Guid.Empty;
            string tenantDomain = string.Empty;

            try
            {
                SmtpAddress smtpAddress = new SmtpAddress(mailboxId);
                guid         = new Guid(smtpAddress.Local);
                tenantDomain = smtpAddress.Domain;
            }
            catch (FormatException arg)
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string, FormatException>(0L, "[MapiAddressFinder::FindByMailboxId]: Caught exception: Reason {0}; Exception {1}.", string.Format("Invalid mailboxGuid {0}", guid), arg);
                return(null);
            }
            IRoutingKey routingKey = new MailboxGuidRoutingKey(guid, tenantDomain);

            diagnostics.AddRoutingkey(routingKey, "MailboxGuidInQueryString");
            return(routingKey);
        }
        IRoutingKey[] IAddressFinder.Find(AddressFinderSource source, IAddressFinderDiagnostics diagnostics)
        {
            AddressFinderHelper.ThrowIfNull(source, diagnostics);
            string text = source.Headers["X-PreferServerAffinity"];

            if (!string.IsNullOrEmpty(text) && text.Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase))
            {
                HttpCookie httpCookie = source.Cookies["X-BackEndOverrideCookie"];
                string     text2      = (httpCookie == null) ? null : httpCookie.Value;
                if (!string.IsNullOrEmpty(text2))
                {
                    string text3;
                    string s;
                    Utilities.GetTwoSubstrings(text2, '~', out text3, out s);
                    int value;
                    if (!string.IsNullOrWhiteSpace(text3) && int.TryParse(s, out value))
                    {
                        IRoutingKey routingKey = new ServerRoutingKey(text3, new int?(value));
                        diagnostics.AddRoutingkey(routingKey, "X-BackEndOverrideCookie");
                        return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[]
                        {
                            routingKey
                        }));
                    }
                    diagnostics.AddErrorInfo("Unable to parse TargetServer:" + text2);
                }
            }
            return(AddressFinderHelper.EmptyRoutingKeyArray);
        }
Example #5
0
        private static IRoutingKey FindByTargetServer(string targetServer, IAddressFinderDiagnostics diagnostics)
        {
            if (string.IsNullOrEmpty(targetServer))
            {
                return(null);
            }
            IRoutingKey routingKey = new ServerRoutingKey(targetServer);

            diagnostics.AddRoutingkey(routingKey, "TargetServerInHeader");
            return(routingKey);
        }
Example #6
0
        IRoutingKey[] IAddressFinder.Find(AddressFinderSource source, IAddressFinderDiagnostics diagnostics)
        {
            AddressFinderHelper.ThrowIfNull(source, diagnostics);
            if (string.IsNullOrEmpty(source.Url.Query))
            {
                return(AddressFinderHelper.EmptyRoutingKeyArray);
            }
            RpcHttpQueryString rpcHttpQueryString = new RpcHttpQueryString(source.Url.Query);

            if (!SmtpAddress.IsValidSmtpAddress(rpcHttpQueryString.RcaServer))
            {
                return(AddressFinderHelper.EmptyRoutingKeyArray);
            }
            Guid   guid = Guid.Empty;
            string text = string.Empty;

            try
            {
                SmtpAddress smtpAddress = new SmtpAddress(rpcHttpQueryString.RcaServer);
                guid = new Guid(smtpAddress.Local);
                text = smtpAddress.Domain;
            }
            catch (FormatException arg)
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string, FormatException>(0L, "[RpcHttpAddressFinder::Find]: Caught exception: Reason {0}; Exception {1}.", string.Format("Invalid mailboxGuid {0}", guid), arg);
                return(AddressFinderHelper.EmptyRoutingKeyArray);
            }
            string text2 = "MailboxGuidWithDomain";

            if (!text.Contains(".") && !source.Items.IsNullOrEmpty())
            {
                string text3 = source.Items["WLID-MemberName"] as string;
                if (!string.IsNullOrEmpty(text3))
                {
                    SmtpAddress smtpAddress2 = new SmtpAddress(text3);
                    string      domain       = smtpAddress2.Domain;
                    if (domain != null && !string.Equals(domain, text, StringComparison.OrdinalIgnoreCase))
                    {
                        ExTraceGlobals.BriefTracer.TraceError <string, string>((long)this.GetHashCode(), "[RpcHttpAddressFinder::Find]: Fixing up invalid domain name from client: {0} to {1}", text, domain);
                        text   = domain;
                        text2 += "-ChangedToUserDomain";
                    }
                }
            }
            IRoutingKey routingKey = new MailboxGuidRoutingKey(guid, text);

            diagnostics.AddRoutingkey(routingKey, text2);
            return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[]
            {
                routingKey
            }));
        }
        IRoutingKey[] IAddressFinder.Find(AddressFinderSource source, IAddressFinderDiagnostics diagnostics)
        {
            AddressFinderHelper.ThrowIfNull(source, diagnostics);
            string text = source.QueryString["email"];

            if (!string.IsNullOrEmpty(text) && SmtpAddress.IsValidSmtpAddress(text))
            {
                IRoutingKey routingKey = new SmtpRoutingKey(new SmtpAddress(text));
                diagnostics.AddRoutingkey(routingKey, "ExplicitLogon-SMTP");
                return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[]
                {
                    routingKey
                }));
            }
            return(AddressFinderHelper.EmptyRoutingKeyArray);
        }
Example #8
0
        private static IRoutingKey FindBySmtpAddress(string smtpAddress, IAddressFinderDiagnostics diagnostics)
        {
            if (string.IsNullOrEmpty(smtpAddress))
            {
                return(null);
            }
            if (!SmtpAddress.IsValidSmtpAddress(smtpAddress))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string>(0L, "[MapiAddressFinder::FindBySmtpAddress]: Malformed smtpAddress {0}.", smtpAddress);
                return(null);
            }
            IRoutingKey routingKey = new SmtpRoutingKey(new SmtpAddress(smtpAddress));

            diagnostics.AddRoutingkey(routingKey, "SmtpAddressInQueryString");
            return(routingKey);
        }
Example #9
0
        IRoutingKey[] IAddressFinder.Find(AddressFinderSource source, IAddressFinderDiagnostics diagnostics)
        {
            AddressFinderHelper.ThrowIfNull(source, diagnostics);
            bool   selectedNodeIsLast;
            string explicitLogonNode = ProtocolHelper.GetExplicitLogonNode(source.ApplicationPath, source.FilePath, ExplicitLogonNode.Second, out selectedNodeIsLast);
            string address;

            if (ProtocolHelper.TryGetValidNormalizedExplicitLogonAddress(explicitLogonNode, selectedNodeIsLast, out address))
            {
                IRoutingKey routingKey = new SmtpRoutingKey(new SmtpAddress(address));
                diagnostics.AddRoutingkey(routingKey, "ExplicitLogon-SMTP");
                return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[]
                {
                    routingKey
                }));
            }
            return(AddressFinderHelper.EmptyRoutingKeyArray);
        }
Example #10
0
 IRoutingKey[] IAddressFinder.Find(AddressFinderSource source, IAddressFinderDiagnostics diagnostics)
 {
     AddressFinderHelper.ThrowIfNull(source, diagnostics);
     if (!string.IsNullOrWhiteSpace(source.Url.PathAndQuery))
     {
         Match match = Constants.UsersEntityRegex.Match(source.Url.PathAndQuery);
         if (match.Success)
         {
             string address = match.Result("${address}");
             if (SmtpAddress.IsValidSmtpAddress(address))
             {
                 IRoutingKey routingKey = new SmtpRoutingKey(new SmtpAddress(address));
                 diagnostics.AddRoutingkey(routingKey, "TargetMailbox-SMTP");
                 return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[]
                 {
                     routingKey
                 }));
             }
         }
     }
     return(AddressFinderHelper.EmptyRoutingKeyArray);
 }