// 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());
        }
Exemple #2
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());
        }