Example #1
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 #2
0
        IRoutingKey[] IAddressFinder.Find(AddressFinderSource source, IAddressFinderDiagnostics diagnostics)
        {
            AddressFinderHelper.ThrowIfNull(source, diagnostics);
            ExTraceGlobals.VerboseTracer.TraceDebug <int>((long)this.GetHashCode(), "[CompositeAddressFinder::Find]: Number of addressFinders {0}.", this.addressFinders.Length);
            if (this.addressFinders.Length == 0)
            {
                return(AddressFinderHelper.EmptyRoutingKeyArray);
            }
            List <IRoutingKey> list = new List <IRoutingKey>(this.addressFinders.Length);

            foreach (IAddressFinder addressFinder in this.addressFinders)
            {
                if (addressFinder != null)
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug <Type>((long)this.GetHashCode(), "[CompositeAddressFinder::Find]: addressFinder {0}.", addressFinder.GetType());
                    IRoutingKey[] collection = addressFinder.Find(source, diagnostics);
                    if (!collection.IsNullOrEmpty())
                    {
                        list.AddRange(collection);
                    }
                }
                else
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[CompositeAddressFinder::Find]: addressFinder is null.");
                }
            }
            if (list.Count == 0)
            {
                return(AddressFinderHelper.EmptyRoutingKeyArray);
            }
            return(list.ToArray());
        }
Example #3
0
        IRoutingKey[] IAddressFinder.Find(AddressFinderSource source, IAddressFinderDiagnostics diagnostics)
        {
            AddressFinderHelper.ThrowIfNull(source, diagnostics);
            List <IRoutingKey> list = new List <IRoutingKey>();

            if (!source.Headers.IsNullOrEmpty())
            {
                IRoutingKey routingKey = RoutingHintAddressFinder.FindByTargetServer(source.Headers[WellKnownHeader.XTargetServer], diagnostics);
                if (routingKey != null)
                {
                    list.Add(routingKey);
                }
                else
                {
                    IRoutingKey[] collection = RoutingHintAddressFinder.FindByAnchorMailbox(source.Headers[WellKnownHeader.AnchorMailbox], diagnostics);
                    if (!collection.IsNullOrEmpty())
                    {
                        list.AddRange(collection);
                    }
                }
            }
            if (list.Count == 0)
            {
                return(AddressFinderHelper.EmptyRoutingKeyArray);
            }
            return(list.ToArray());
        }
        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
        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 #7
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 #8
0
        IRoutingKey[] IAddressFinder.Find(AddressFinderSource source, IAddressFinderDiagnostics diagnostics)
        {
            AddressFinderHelper.ThrowIfNull(source, diagnostics);
            List <IRoutingKey> list       = new List <IRoutingKey>();
            IRoutingKey        routingKey = MapiAddressFinder.FindByMailboxId(source.QueryString["mailboxId"], diagnostics);

            if (routingKey != null)
            {
                list.Add(routingKey);
            }
            routingKey = MapiAddressFinder.FindBySmtpAddress(source.QueryString["smtpAddress"], diagnostics);
            if (routingKey != null)
            {
                list.Add(routingKey);
            }
            if (list.Count == 0)
            {
                return(AddressFinderHelper.EmptyRoutingKeyArray);
            }
            return(list.ToArray());
        }
Example #9
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);
 }