protected override AnchorMailbox ResolveAnchorMailbox()
 {
     if (AutodiscoverProxyRequestHandler.LoadBalancedPartnerRouting.Value && base.ClientRequest.Url.AbsolutePath.ToLower().Contains("/wssecurity/x509cert"))
     {
         string text  = base.ClientRequest.Headers[Constants.AnchorMailboxHeaderName];
         string text2 = null;
         if (string.IsNullOrEmpty(text))
         {
             AnchorMailbox anchorMailbox = base.TryGetAnchorMailboxFromWsSecurityRequest();
             if (anchorMailbox != null)
             {
                 SmtpAnchorMailbox smtpAnchorMailbox = anchorMailbox as SmtpAnchorMailbox;
                 if (smtpAnchorMailbox != null)
                 {
                     text2 = smtpAnchorMailbox.Smtp;
                 }
                 else
                 {
                     DomainAnchorMailbox domainAnchorMailbox = anchorMailbox as DomainAnchorMailbox;
                     if (domainAnchorMailbox != null)
                     {
                         text2 = domainAnchorMailbox.Domain;
                     }
                 }
             }
         }
         else
         {
             text2 = text;
         }
         if (!string.IsNullOrEmpty(text2))
         {
             bool flag = text2.EndsWith(AutodiscoverProxyRequestHandler.BlackBerryTenantName.Value, StringComparison.OrdinalIgnoreCase);
             if (flag)
             {
                 base.Logger.SafeSet(HttpProxyMetadata.RoutingHint, "PartnerX509Request");
                 return(new TargetForestAnchorMailbox(this, AutodiscoverProxyRequestHandler.BlackBerryTenantName.Value, false));
             }
         }
     }
     return(base.ResolveAnchorMailbox());
 }
        // 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());
        }
Ejemplo n.º 3
0
        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(HttpProxyMetadata.RoutingHint, "TargetServer");
                return(new ServerInfoAnchorMailbox(text, this));
            }
            string text2 = nameValueCollection["ExchClientVer"];

            if (!string.IsNullOrWhiteSpace(text2))
            {
                text2 = Utilities.NormalizeExchClientVer(text2);
            }
            if (!Utilities.IsPartnerHostedOnly && !VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled)
            {
                base.Logger.Set(HttpProxyMetadata.RoutingHint, "ExchClientVer");
                return(base.GetServerVersionAnchorMailbox(text2));
            }
            bool   flag;
            string text3;
            string routingBasedOrganization = this.GetRoutingBasedOrganization(nameValueCollection, out flag, out text3);

            if (!this.isSyndicatedAdmin && !string.IsNullOrWhiteSpace(text2))
            {
                if (!string.IsNullOrWhiteSpace(routingBasedOrganization))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[RemotePowerShellProxyRequestHandler::ResolveAnchorMailbox]: Datacenter, Version parameter {0}, from {1}, organization {2}, context {3}.", new object[]
                    {
                        text2,
                        text3,
                        routingBasedOrganization,
                        base.TraceContext
                    });
                    base.Logger.Set(HttpProxyMetadata.RoutingHint, text3 + "-" + text2);
                    return(VersionedDomainAnchorMailbox.GetAnchorMailbox(routingBasedOrganization, text2, this));
                }
                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}.", text2, base.TraceContext);
            }
            string text4 = nameValueCollection["DelegatedUser"];

            if (!string.IsNullOrEmpty(text4))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string, int>((long)this.GetHashCode(), "[RemotePowerShellProxyRequestHandler::ResolveAnchorMailbox]: User hint {0}, context {1}.", text4, base.TraceContext);
                if (!string.IsNullOrEmpty(text4) && SmtpAddress.IsValidSmtpAddress(text4))
                {
                    base.Logger.Set(HttpProxyMetadata.RoutingHint, "DelegatedUser-SMTP-UrlQuery");
                    return(new SmtpAnchorMailbox(text4, this));
                }
            }
            if (flag)
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string, string, int>((long)this.GetHashCode(), "[RemotePowerShellProxyRequestHandler::ResolveAnchorMailbox]: Organization-based. Organization {0} from {1}, context {2}.", routingBasedOrganization, text3, base.TraceContext);
                DomainAnchorMailbox domainAnchorMailbox = new DomainAnchorMailbox(routingBasedOrganization, this);
                if (this.isSyndicatedAdmin && !this.IsSecurityTokenPresent())
                {
                    ADRawEntry            adrawEntry            = domainAnchorMailbox.GetADRawEntry();
                    ExchangeObjectVersion exchangeObjectVersion = adrawEntry[OrganizationConfigSchema.AdminDisplayVersion] as ExchangeObjectVersion;
                    if (exchangeObjectVersion.ExchangeBuild.Major < ExchangeObjectVersion.Exchange2012.ExchangeBuild.Major)
                    {
                        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(HttpProxyMetadata.RoutingHint, text3);
                return(domainAnchorMailbox);
            }
            return(base.ResolveAnchorMailbox());
        }
Ejemplo n.º 4
0
        private AnchorMailbox LegacyResolveAnchorMailbox()
        {
            AnchorMailbox anchorMailbox = null;

            if (base.UseRoutingHintForAnchorMailbox)
            {
                string text = base.ClientRequest.Headers["X-OWA-ExplicitLogonUser"];
                if (!string.IsNullOrEmpty(text) && SmtpAddress.IsValidSmtpAddress(text))
                {
                    base.IsExplicitSignOn      = true;
                    base.ExplicitSignOnAddress = text;
                    base.Logger.Set(HttpProxyMetadata.RoutingHint, "ExplicitLogon-SMTP-Header");
                    anchorMailbox = new SmtpAnchorMailbox(text, this);
                }
                else
                {
                    text = this.TryGetExplicitLogonNode(ExplicitLogonNode.Second);
                    if (!string.IsNullOrEmpty(text))
                    {
                        if (SmtpAddress.IsValidSmtpAddress(text))
                        {
                            base.IsExplicitSignOn      = true;
                            base.ExplicitSignOnAddress = text;
                            base.Logger.Set(HttpProxyMetadata.RoutingHint, "ExplicitLogon-SMTP");
                            anchorMailbox = new SmtpAnchorMailbox(text, this);
                        }
                        else if ((Utilities.IsPartnerHostedOnly || VariantConfiguration.InvariantNoFlightingSnapshot.Cafe.ExplicitDomain.Enabled) && SmtpAddress.IsValidDomain(text))
                        {
                            string domain = text;
                            text = this.TryGetExplicitLogonNode(ExplicitLogonNode.Third);
                            if (text == null)
                            {
                                base.Logger.Set(HttpProxyMetadata.RoutingHint, "ExplicitLogon-Domain");
                                anchorMailbox = new DomainAnchorMailbox(domain, this);
                            }
                            else
                            {
                                base.IsExplicitSignOn      = true;
                                base.ExplicitSignOnAddress = text;
                                base.Logger.Set(HttpProxyMetadata.RoutingHint, "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);
        }
Ejemplo n.º 5
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);
        }