// Token: 0x0600073B RID: 1851 RVA: 0x0002A6F4 File Offset: 0x000288F4
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string, Uri>((long)this.GetHashCode(), "[SiteMailboxCreatingProxyRequestHandler::ResolveAnchorMailbox]: Method {0}; Url {1};", base.ClientRequest.HttpMethod, base.ClientRequest.Url);
            }
            if (!Utilities.IsPartnerHostedOnly && !GlobalConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MultiTenancy.Enabled)
            {
                base.Logger.Set(3, "SiteMailboxCreating-ServerVersion");
                return(new ServerVersionAnchorMailbox <EcpService>(new ServerVersion(Server.E15MinVersion), 0, this));
            }
            AnchorMailbox anchorMailbox = AnchorMailboxFactory.CreateFromCaller(this);

            if (anchorMailbox is AnonymousAnchorMailbox)
            {
                return(anchorMailbox);
            }
            if (anchorMailbox is DomainAnchorMailbox || anchorMailbox is OrganizationAnchorMailbox)
            {
                return(anchorMailbox);
            }
            SidAnchorMailbox sidAnchorMailbox = anchorMailbox as SidAnchorMailbox;

            if (sidAnchorMailbox != null)
            {
                if (sidAnchorMailbox.OrganizationId == null)
                {
                    throw new InvalidOperationException(string.Format("OrganizationId is null for site mailbox proxy {0}.", anchorMailbox.ToString()));
                }
                base.Logger.Set(3, "SiteMailboxCreating-Organization");
                return(new OrganizationAnchorMailbox(sidAnchorMailbox.OrganizationId, this));
            }
            else
            {
                UserBasedAnchorMailbox userBasedAnchorMailbox = anchorMailbox as UserBasedAnchorMailbox;
                if (userBasedAnchorMailbox == null)
                {
                    throw new InvalidOperationException(string.Format("Unknown site mailbox proxy {0}.", anchorMailbox.ToString()));
                }
                OrganizationId organizationId = (OrganizationId)userBasedAnchorMailbox.GetADRawEntry()[ADObjectSchema.OrganizationId];
                if (organizationId == null)
                {
                    throw new InvalidOperationException(string.Format("OrganizationId is null for site mailbox proxy {0}.", anchorMailbox.ToString()));
                }
                base.Logger.Set(3, "SiteMailboxCreating-Organization");
                return(new OrganizationAnchorMailbox(organizationId, this));
            }
        }
        private string ResolveUserAddress(AnchorMailbox anchorMailbox)
        {
            SidAnchorMailbox sidAnchorMailbox = anchorMailbox as SidAnchorMailbox;

            if (sidAnchorMailbox != null && !string.IsNullOrEmpty(sidAnchorMailbox.SmtpOrLiveId))
            {
                return(sidAnchorMailbox.SmtpOrLiveId);
            }
            SmtpAnchorMailbox smtpAnchorMailbox = anchorMailbox as SmtpAnchorMailbox;

            if (smtpAnchorMailbox != null)
            {
                return(smtpAnchorMailbox.Smtp);
            }
            UserBasedAnchorMailbox userBasedAnchorMailbox = (UserBasedAnchorMailbox)anchorMailbox;

            return(string.Format("anyone@{0}", userBasedAnchorMailbox.GetDomainName()));
        }
 // Token: 0x060005AA RID: 1450 RVA: 0x0001F7D8 File Offset: 0x0001D9D8
 private void OnProxyLogonResponseReady(object extraData)
 {
     base.CallThreadEntranceMethod(delegate
     {
         IAsyncResult asyncResult = extraData as IAsyncResult;
         object lockObject        = this.LockObject;
         lock (lockObject)
         {
             try
             {
                 GuardedProxyExecution.Default.Decrement(this.AnchoredRoutingTarget.BackEndServer);
                 this.proxyLogonResponse = (HttpWebResponse)this.proxyLogonRequest.EndGetResponse(asyncResult);
                 this.PfdTracer.TraceResponse("ProxyLogonResponse", this.proxyLogonResponse);
                 this.proxyLogonResponseCookies = this.proxyLogonResponse.Cookies;
                 this.proxyLogonResponse.Close();
                 this.proxyLogonResponse             = null;
                 UserContextCookie userContextCookie = this.TryGetUserContextFromProxyLogonResponse();
                 if (userContextCookie != null && userContextCookie.MailboxUniqueKey != null)
                 {
                     string mailboxUniqueKey = userContextCookie.MailboxUniqueKey;
                     if (SmtpAddress.IsValidSmtpAddress(mailboxUniqueKey))
                     {
                         AnchorMailbox anchorMailbox = new SmtpAnchorMailbox(ProxyAddress.Parse("SMTP", mailboxUniqueKey).AddressString, this);
                         this.AnchoredRoutingTarget  = new AnchoredRoutingTarget(anchorMailbox, this.AnchoredRoutingTarget.BackEndServer);
                     }
                     else
                     {
                         try
                         {
                             AnchorMailbox anchorMailbox2 = new SidAnchorMailbox(new SecurityIdentifier(mailboxUniqueKey), this);
                             this.AnchoredRoutingTarget   = new AnchoredRoutingTarget(anchorMailbox2, this.AnchoredRoutingTarget.BackEndServer);
                         }
                         catch (ArgumentException)
                         {
                         }
                     }
                 }
                 ThreadPool.QueueUserWorkItem(new WaitCallback(this.BeginProxyRequest));
                 this.State = ProxyRequestHandler.ProxyState.PrepareServerRequest;
             }
             catch (WebException ex)
             {
                 if (ex.Status == WebExceptionStatus.ProtocolError && ((HttpWebResponse)ex.Response).StatusCode == (HttpStatusCode)442)
                 {
                     this.RedirectOn442Response();
                 }
                 else
                 {
                     this.CompleteWithError(ex, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
                 }
             }
             catch (HttpException ex2)
             {
                 this.CompleteWithError(ex2, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
             }
             catch (IOException ex3)
             {
                 this.CompleteWithError(ex3, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
             }
             catch (HttpProxyException ex4)
             {
                 this.CompleteWithError(ex4, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
             }
         }
     });
 }