protected override AnchorMailboxCacheEntry RefreshCacheEntry()
        {
            ADRawEntry adrawEntry = this.GetADRawEntry();

            if (adrawEntry == null)
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <UserBasedAnchorMailbox>((long)this.GetHashCode(), "[UserBasedAnchorMailbox::RefreshCacheEntry]: Anchor mailbox {0} has no AD object. Will use random server.", this);
                return(new AnchorMailboxCacheEntry());
            }
            string domainNameFromADRawEntry = UserBasedAnchorMailbox.GetDomainNameFromADRawEntry(adrawEntry);

            ExTraceGlobals.VerboseTracer.TraceDebug <UserBasedAnchorMailbox, string>((long)this.GetHashCode(), "[UserBasedAnchorMailbox::RefreshCacheEntry]: The domain name of anchor mailbox {0} is {1}.", this, domainNameFromADRawEntry);
            ADObjectId adobjectId = (ADObjectId)adrawEntry[this.DatabaseProperty];

            if (adobjectId == null && this.MissingDatabaseHandler != null)
            {
                adobjectId = this.MissingDatabaseHandler(adrawEntry);
            }
            if (adobjectId == null)
            {
                base.RequestContext.Logger.AppendString(HttpProxyMetadata.RoutingHint, "-NoDatabase");
                OrganizationId organizationId             = (OrganizationId)adrawEntry[ADObjectSchema.OrganizationId];
                ADUser         defaultOrganizationMailbox = HttpProxyBackEndHelper.GetDefaultOrganizationMailbox(organizationId, (string)adrawEntry[ADObjectSchema.DistinguishedName]);
                if (defaultOrganizationMailbox == null || defaultOrganizationMailbox.Database == null)
                {
                    if ((Utilities.IsPartnerHostedOnly || VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled) && OrganizationId.ForestWideOrgId.Equals(organizationId))
                    {
                        ExTraceGlobals.VerboseTracer.TraceDebug <ADObjectId>((long)this.GetHashCode(), "[UserBasedAnchorMailbox::RefreshCacheEntry]: Cannot find organization mailbox for datacenter FirstOrg user {0}. Will use random server.", adrawEntry.Id);
                        return(new AnchorMailboxCacheEntry
                        {
                            DomainName = domainNameFromADRawEntry
                        });
                    }
                    string text = string.Format("Unable to find organization mailbox for organization {0}", organizationId);
                    ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[UserBasedAnchorMailbox::RefreshCacheEntry]: {0}", text);
                    throw new HttpProxyException(HttpStatusCode.InternalServerError, HttpProxySubErrorCode.OrganizationMailboxNotFound, text);
                }
                else
                {
                    adobjectId = defaultOrganizationMailbox.Database;
                    ExTraceGlobals.VerboseTracer.TraceDebug <ADObjectId, ObjectId, ADObjectId>((long)this.GetHashCode(), "[UserBasedAnchorMailbox::RefreshCacheEntry]: Anchor mailbox user {0} has no mailbox. Will use organization mailbox {1} with database {2}", adrawEntry.Id, defaultOrganizationMailbox.Identity, adobjectId);
                }
            }
            return(new AnchorMailboxCacheEntry
            {
                Database = adobjectId,
                DomainName = domainNameFromADRawEntry
            });
        }
        // 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));
            }
        }
Beispiel #3
0
 private void RedirectIfNeeded()
 {
     if (!this.IsSecurityTokenPresent())
     {
         UserBasedAnchorMailbox userBasedAnchorMailbox = AnchorMailboxFactory.CreateFromCaller(this) as UserBasedAnchorMailbox;
         if (userBasedAnchorMailbox != null)
         {
             ADRawEntry adrawEntry = userBasedAnchorMailbox.GetADRawEntry();
             ExTraceGlobals.VerboseTracer.TraceDebug <UserBasedAnchorMailbox, ExchangeObjectVersion>((long)this.GetHashCode(), "[RemotePowerShellProxyRequestHandler::RedirectIfNeeded] Redirect if the user is in E14 forest. User: {0}; ExchangeVersion: {1}", userBasedAnchorMailbox, adrawEntry.ExchangeVersion);
             if (adrawEntry.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2012))
             {
                 base.Logger.AppendGenericInfo("RedirectReason", "NoSecurityTokenAndOlderThanE15");
                 base.DatacenterRedirectStrategy.RedirectMailbox(userBasedAnchorMailbox);
             }
         }
     }
 }
        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()));
        }
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            string text = base.HttpContext.Items["destination"] as string;
            Uri    uri;

            if (!Uri.TryCreate(text, UriKind.Absolute, out uri))
            {
                throw new HttpException(400, "destination value is not valid");
            }
            string text2 = null;
            bool   flag2;
            string text3;
            bool   flag = FbaFormPostProxyRequestHandler.IsExplicitLogon(HttpRuntime.AppDomainAppVirtualPath, uri.PathAndQuery, uri.OriginalString, out flag2, out text2, out text3);

            if (flag)
            {
                this.explicitLogonUser = text2;
            }
            AnchorMailbox anchorMailbox;

            if (!string.IsNullOrEmpty(this.explicitLogonUser))
            {
                anchorMailbox = new SmtpAnchorMailbox(this.explicitLogonUser, this);
            }
            else
            {
                anchorMailbox = AnchorMailboxFactory.CreateFromCaller(this);
            }
            UserBasedAnchorMailbox userBasedAnchorMailbox = anchorMailbox as UserBasedAnchorMailbox;

            if (userBasedAnchorMailbox != null)
            {
                if (UrlUtilities.IsEacUrl(text))
                {
                    userBasedAnchorMailbox.CacheKeyPostfix = "_EAC";
                }
                else
                {
                    userBasedAnchorMailbox.MissingDatabaseHandler = new Func <ADRawEntry, ADObjectId>(base.ResolveMailboxDatabase);
                }
            }
            return(anchorMailbox);
        }
Beispiel #6
0
 // Token: 0x06000509 RID: 1289 RVA: 0x0001BAC4 File Offset: 0x00019CC4
 protected override void AddProtocolSpecificHeadersToServerRequest(WebHeaderCollection headers)
 {
     headers[Constants.LiveIdEnvironment] = (string)base.HttpContext.Items[Constants.LiveIdEnvironment];
     headers[Constants.LiveIdPuid]        = (string)base.HttpContext.Items[Constants.LiveIdPuid];
     headers[Constants.OrgIdPuid]         = (string)base.HttpContext.Items[Constants.OrgIdPuid];
     headers[Constants.LiveIdMemberName]  = (string)base.HttpContext.Items[Constants.LiveIdMemberName];
     headers["msExchClientPath"]          = Uri.EscapeDataString(base.ClientRequest.Path);
     if (this.isSyndicatedAdminManageDownLevelTarget)
     {
         headers["msExchCafeForceRouteToLogonAccount"] = "1";
     }
     if (!this.IsCrossForestDelegated && base.ProxyToDownLevel)
     {
         EcpProxyRequestHandler.AddDownLevelProxyHeaders(headers, base.HttpContext);
         if (base.IsExplicitSignOn)
         {
             string value = null;
             AnchoredRoutingTarget anchoredRoutingTarget = this.isSyndicatedAdminManageDownLevelTarget ? this.originalAnchoredRoutingTarget : base.AnchoredRoutingTarget;
             if (anchoredRoutingTarget != null)
             {
                 UserBasedAnchorMailbox userBasedAnchorMailbox = anchoredRoutingTarget.AnchorMailbox as UserBasedAnchorMailbox;
                 if (userBasedAnchorMailbox != null)
                 {
                     ADRawEntry adrawEntry = userBasedAnchorMailbox.GetADRawEntry();
                     if (adrawEntry != null)
                     {
                         SecurityIdentifier securityIdentifier = adrawEntry[ADMailboxRecipientSchema.Sid] as SecurityIdentifier;
                         if (securityIdentifier != null)
                         {
                             value = securityIdentifier.ToString();
                         }
                     }
                 }
             }
             headers["msExchTargetMailbox"] = value;
         }
     }
     base.AddProtocolSpecificHeadersToServerRequest(headers);
 }
Beispiel #7
0
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            AnchorMailbox          anchorMailbox          = null;
            AnchorMailbox          anchorMailbox2         = base.ResolveAnchorMailbox();
            UserBasedAnchorMailbox userBasedAnchorMailbox = anchorMailbox2 as UserBasedAnchorMailbox;

            if (userBasedAnchorMailbox == null)
            {
                return(anchorMailbox2);
            }
            userBasedAnchorMailbox.UseServerCookie = true;
            string targetOrgMailbox = base.HttpContext.Request.Headers["TargetOrgMailbox"];
            Guid   guid             = Guid.Empty;

            if (!string.IsNullOrEmpty(targetOrgMailbox))
            {
                IRecipientSession session    = DirectoryHelper.GetRecipientSessionFromSmtpOrLiveId(base.LatencyTracker, targetOrgMailbox, false);
                ADRawEntry        adrawEntry = DirectoryHelper.InvokeAccountForest(base.LatencyTracker, () => OrganizationMailbox.GetOrganizationMailboxByUPNAndCapability(session, targetOrgMailbox, OrganizationCapability.OABGen));
                if (adrawEntry != null)
                {
                    anchorMailbox = new UserADRawEntryAnchorMailbox(adrawEntry, this);
                }
            }
            else
            {
                AnchoredRoutingTarget anchoredRoutingTarget = this.TryFastTargetCalculationByAnchorMailbox(anchorMailbox2);
                if (anchoredRoutingTarget != null)
                {
                    return(anchoredRoutingTarget.AnchorMailbox);
                }
                ADRawEntry adrawEntry2 = userBasedAnchorMailbox.GetADRawEntry();
                if (adrawEntry2 == null)
                {
                    return(anchorMailbox2);
                }
                guid = OABRequestUrl.GetOabGuidFromRequest(base.HttpContext.Request);
                if (guid == Guid.Empty)
                {
                    return(anchorMailbox2);
                }
                OrganizationId organizationId     = (OrganizationId)adrawEntry2[ADObjectSchema.OrganizationId];
                string         userAcceptedDomain = null;
                if (organizationId != OrganizationId.ForestWideOrgId)
                {
                    userAcceptedDomain = ((SmtpAddress)adrawEntry2[ADRecipientSchema.PrimarySmtpAddress]).Domain;
                }
                OABCache.OABCacheEntry oabfromCacheOrAD = OABCache.Instance.GetOABFromCacheOrAD(guid, userAcceptedDomain);
                if (oabfromCacheOrAD.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2012))
                {
                    anchorMailbox = this.GetE14CASServer(oabfromCacheOrAD);
                }
                else
                {
                    ADRawEntry adrawEntry3 = null;
                    if (OABVariantConfigurationSettings.IsLinkedOABGenMailboxesEnabled && !oabfromCacheOrAD.ShadowMailboxDistributionEnabled && oabfromCacheOrAD.GeneratingMailbox != null)
                    {
                        IRecipientSession recipientSessionFromOrganizationId = DirectoryHelper.GetRecipientSessionFromOrganizationId(base.LatencyTracker, organizationId);
                        adrawEntry3 = recipientSessionFromOrganizationId.Read(oabfromCacheOrAD.GeneratingMailbox);
                    }
                    if (adrawEntry3 == null)
                    {
                        if (OABVariantConfigurationSettings.IsSkipServiceTopologyDiscoveryEnabled)
                        {
                            adrawEntry3 = HttpProxyBackEndHelper.GetOrganizationMailbox(organizationId, OrganizationCapability.OABGen, null);
                        }
                        else
                        {
                            adrawEntry3 = HttpProxyBackEndHelper.GetOrganizationMailboxInClosestSite(organizationId, OrganizationCapability.OABGen);
                        }
                    }
                    if (adrawEntry3 != null)
                    {
                        anchorMailbox = new UserADRawEntryAnchorMailbox(adrawEntry3, this)
                        {
                            UseServerCookie = true
                        };
                    }
                }
            }
            if (anchorMailbox == null)
            {
                ExTraceGlobals.VerboseTracer.TraceError(0L, "[OabProxyRequestHandler::ResolveAnchorMailbox] Unable to locate appropriate server for OAB");
                string message;
                if (string.IsNullOrEmpty(targetOrgMailbox))
                {
                    message = string.Format("Unable to locate appropriate server for OAB {0}.", guid);
                }
                else
                {
                    message = string.Format("Unable to locate organization mailbox {0}", targetOrgMailbox);
                }
                throw new HttpProxyException(HttpStatusCode.InternalServerError, HttpProxySubErrorCode.OrganizationMailboxNotFound, message);
            }
            ExTraceGlobals.VerboseTracer.TraceDebug <AnchorMailbox>(0L, "[OabProxyRequestHandler::ResolveAnchorMailbox] Proxying OAB request using anchor {0}.", anchorMailbox);
            string value = string.Format("{0}-{1}", base.Logger.Get(HttpProxyMetadata.RoutingHint), "OABOrgMailbox");

            base.Logger.Set(HttpProxyMetadata.RoutingHint, value);
            anchorMailbox.OriginalAnchorMailbox = anchorMailbox2;
            return(anchorMailbox);
        }
Beispiel #8
0
        // Token: 0x0600057D RID: 1405 RVA: 0x0001E8E8 File Offset: 0x0001CAE8
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            AnchorMailbox          anchorMailbox          = null;
            AnchorMailbox          anchorMailbox2         = base.ResolveAnchorMailbox();
            UserBasedAnchorMailbox userBasedAnchorMailbox = anchorMailbox2 as UserBasedAnchorMailbox;

            if (userBasedAnchorMailbox == null)
            {
                return(anchorMailbox2);
            }
            ADRawEntry adrawEntry = userBasedAnchorMailbox.GetADRawEntry();

            if (OABConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).SingleUserOab.Enabled&& (Globals.IsOabDownloadRequestFromConsumer(base.HttpContext.Request.Url.OriginalString) || (adrawEntry != null && adrawEntry[ADObjectSchema.OrganizationId] != null && Globals.IsConsumerOrganization((OrganizationId)adrawEntry[ADObjectSchema.OrganizationId]))))
            {
                return(userBasedAnchorMailbox);
            }
            userBasedAnchorMailbox.UseServerCookie = true;
            string targetOrgMailbox = base.HttpContext.Request.Headers["TargetOrgMailbox"];
            Guid   guid             = Guid.Empty;

            if (!string.IsNullOrEmpty(targetOrgMailbox))
            {
                IRecipientSession session     = DirectoryHelper.GetRecipientSessionFromSmtpOrLiveId(targetOrgMailbox, base.Logger, base.LatencyTracker, false);
                ADRawEntry        adrawEntry2 = DirectoryHelper.InvokeAccountForest <ADUser>(base.LatencyTracker, () => OrganizationMailbox.GetOrganizationMailboxByUPNAndCapability(session, targetOrgMailbox, 42), base.Logger, session);
                if (adrawEntry2 != null)
                {
                    anchorMailbox = new UserADRawEntryAnchorMailbox(adrawEntry2, this);
                }
            }
            else
            {
                AnchoredRoutingTarget anchoredRoutingTarget = this.TryFastTargetCalculationByAnchorMailbox(anchorMailbox2);
                if (anchoredRoutingTarget != null)
                {
                    return(anchoredRoutingTarget.AnchorMailbox);
                }
                if (adrawEntry == null)
                {
                    return(anchorMailbox2);
                }
                guid = OABRequestUrl.GetOabGuidFromRequest(base.HttpContext.Request);
                if (guid == Guid.Empty)
                {
                    return(anchorMailbox2);
                }
                OrganizationId organizationId     = (OrganizationId)adrawEntry[ADObjectSchema.OrganizationId];
                string         userAcceptedDomain = null;
                if (organizationId != OrganizationId.ForestWideOrgId)
                {
                    userAcceptedDomain = ((SmtpAddress)adrawEntry[ADRecipientSchema.PrimarySmtpAddress]).Domain;
                }
                OABCache.OABCacheEntry oabcacheEntry = null;
                try
                {
                    oabcacheEntry = OABCache.Instance.GetOABFromCacheOrAD(guid, userAcceptedDomain);
                }
                catch (ADNoSuchObjectException ex)
                {
                    throw new HttpProxyException(HttpStatusCode.NotFound, 3001, "ADNoSuchObjectException: OAB is not in the cache and cannot be found from the AD! " + ex.Message);
                }
                if (oabcacheEntry.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2012))
                {
                    anchorMailbox = this.GetE14CASServer(oabcacheEntry);
                }
                else
                {
                    ADRawEntry adrawEntry3 = null;
                    if (OABVariantConfigurationSettings.IsLinkedOABGenMailboxesEnabled && !oabcacheEntry.ShadowMailboxDistributionEnabled && oabcacheEntry.GeneratingMailbox != null)
                    {
                        adrawEntry3 = DirectoryHelper.GetRecipientSessionFromOrganizationId(base.LatencyTracker, organizationId, base.Logger).Read(oabcacheEntry.GeneratingMailbox, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\OabProxyRequestHandler.cs", 200, "ResolveAnchorMailbox");
                    }
                    if (adrawEntry3 == null)
                    {
                        if (OABVariantConfigurationSettings.IsSkipServiceTopologyDiscoveryEnabled)
                        {
                            adrawEntry3 = HttpProxyBackEndHelper.GetOrganizationMailboxWithOABGenCapability(organizationId);
                        }
                        else
                        {
                            adrawEntry3 = HttpProxyBackEndHelper.GetOrganizationMailboxInClosestSite(organizationId, 42);
                        }
                    }
                    if (adrawEntry3 != null)
                    {
                        anchorMailbox = new UserADRawEntryAnchorMailbox(adrawEntry3, this)
                        {
                            UseServerCookie = true
                        };
                    }
                }
            }
            if (anchorMailbox == null)
            {
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(3))
                {
                    ExTraceGlobals.VerboseTracer.TraceError(0L, "[OabProxyRequestHandler::ResolveAnchorMailbox] Unable to locate appropriate server for OAB");
                }
                string message;
                if (string.IsNullOrEmpty(targetOrgMailbox))
                {
                    message = string.Format("Unable to locate appropriate server for OAB {0}.", guid);
                }
                else
                {
                    message = string.Format("Unable to locate organization mailbox {0}", targetOrgMailbox);
                }
                throw new HttpProxyException(HttpStatusCode.InternalServerError, 3006, message);
            }
            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <AnchorMailbox>(0L, "[OabProxyRequestHandler::ResolveAnchorMailbox] Proxying OAB request using anchor {0}.", anchorMailbox);
            }
            string text = string.Format("{0}-{1}", base.Logger.Get(3), "OABOrgMailbox");

            base.Logger.Set(3, text);
            anchorMailbox.OriginalAnchorMailbox = anchorMailbox2;
            return(anchorMailbox);
        }
Beispiel #9
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);
        }
Beispiel #10
0
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            if (base.AuthBehavior.IsFullyAuthenticated())
            {
                return(this.LegacyResolveAnchorMailbox());
            }
            base.HasPreemptivelyCheckedForRoutingHint = true;
            string        text = base.HttpContext.Request.Headers["X-UpnAnchorMailbox"];
            AnchorMailbox anchorMailbox;

            if (string.IsNullOrWhiteSpace(text))
            {
                anchorMailbox = base.CreateAnchorMailboxFromRoutingHint();
            }
            else
            {
                base.Logger.SafeSet(HttpProxyMetadata.RoutingHint, "OwaEcpUpn");
                anchorMailbox = new LiveIdMemberNameAnchorMailbox(text, null, this);
            }
            string text2 = base.ClientRequest.Headers["X-OWA-ExplicitLogonUser"];

            if (anchorMailbox == null)
            {
                if (base.UseRoutingHintForAnchorMailbox)
                {
                    if (!string.IsNullOrEmpty(text2) && SmtpAddress.IsValidSmtpAddress(text2))
                    {
                        base.IsExplicitSignOn      = true;
                        base.ExplicitSignOnAddress = text2;
                        base.Logger.Set(HttpProxyMetadata.RoutingHint, "ExplicitLogon-SMTP-Header");
                        anchorMailbox = new SmtpAnchorMailbox(text2, this);
                    }
                    else
                    {
                        text2 = this.TryGetExplicitLogonNode(ExplicitLogonNode.Second);
                        if (!string.IsNullOrEmpty(text2))
                        {
                            if (SmtpAddress.IsValidSmtpAddress(text2))
                            {
                                base.IsExplicitSignOn      = true;
                                base.ExplicitSignOnAddress = text2;
                                base.Logger.Set(HttpProxyMetadata.RoutingHint, "ExplicitLogon-SMTP");
                                anchorMailbox = new SmtpAnchorMailbox(text2, this);
                            }
                            else if ((Utilities.IsPartnerHostedOnly || VariantConfiguration.InvariantNoFlightingSnapshot.Cafe.ExplicitDomain.Enabled) && SmtpAddress.IsValidDomain(text2))
                            {
                                text2 = this.TryGetExplicitLogonNode(ExplicitLogonNode.Third);
                                if (text2 != null)
                                {
                                    base.IsExplicitSignOn      = true;
                                    base.ExplicitSignOnAddress = text2;
                                    base.Logger.Set(HttpProxyMetadata.RoutingHint, "ExplicitLogon-SMTP");
                                    anchorMailbox = new SmtpAnchorMailbox(text2, this);
                                }
                            }
                        }
                    }
                }
                if (anchorMailbox == null)
                {
                    anchorMailbox = base.ResolveAnchorMailbox();
                }
                else
                {
                    base.IsAnchorMailboxFromRoutingHint         = true;
                    this.originalAnchorMailboxFromExplicitLogon = anchorMailbox;
                }
            }
            else if (!string.IsNullOrWhiteSpace(text2))
            {
                if (!string.Equals(anchorMailbox.SourceObject.ToString(), text2, StringComparison.InvariantCultureIgnoreCase))
                {
                    RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(base.Logger, "ExplicitLogonMismatch", string.Format("{0}~{1}", anchorMailbox.SourceObject, text2));
                }
                this.originalAnchorMailboxFromExplicitLogon = anchorMailbox;
            }
            UserBasedAnchorMailbox userBasedAnchorMailbox = anchorMailbox as UserBasedAnchorMailbox;

            if (userBasedAnchorMailbox != null)
            {
                userBasedAnchorMailbox.MissingDatabaseHandler = new Func <ADRawEntry, ADObjectId>(this.ResolveMailboxDatabase);
            }
            return(anchorMailbox);
        }
        // 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);
        }
        // Token: 0x060005CA RID: 1482 RVA: 0x000200D0 File Offset: 0x0001E2D0
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            if (base.AuthBehavior.IsFullyAuthenticated())
            {
                return(this.LegacyResolveAnchorMailbox());
            }
            base.HasPreemptivelyCheckedForRoutingHint = true;
            string        liveIdMemberName;
            AnchorMailbox anchorMailbox;

            if (!RequestHeaderParser.TryGetAnchorMailboxUpn(base.ClientRequest.Headers, ref liveIdMemberName))
            {
                anchorMailbox = base.CreateAnchorMailboxFromRoutingHint();
            }
            else
            {
                base.Logger.SafeSet(3, "OwaEcpUpn");
                anchorMailbox = new LiveIdMemberNameAnchorMailbox(liveIdMemberName, null, this);
            }
            string text;

            RequestHeaderParser.TryGetExplicitLogonSmtp(base.ClientRequest.Headers, ref text);
            if (anchorMailbox == null)
            {
                if (base.UseRoutingHintForAnchorMailbox)
                {
                    if (!string.IsNullOrEmpty(text) && SmtpAddress.IsValidSmtpAddress(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))
                            {
                                text = this.TryGetExplicitLogonNode(1);
                                if (text != null)
                                {
                                    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;
                }
            }
            else if (!string.IsNullOrWhiteSpace(text))
            {
                if (!string.Equals(anchorMailbox.SourceObject.ToString(), text, StringComparison.InvariantCultureIgnoreCase))
                {
                    RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(base.Logger, "ExplicitLogonMismatch", string.Format("{0}~{1}", anchorMailbox.SourceObject, text));
                }
                this.originalAnchorMailboxFromExplicitLogon = anchorMailbox;
            }
            UserBasedAnchorMailbox userBasedAnchorMailbox = anchorMailbox as UserBasedAnchorMailbox;

            if (userBasedAnchorMailbox != null)
            {
                userBasedAnchorMailbox.MissingDatabaseHandler = new Func <ADRawEntry, ADObjectId>(this.ResolveMailboxDatabase);
            }
            return(anchorMailbox);
        }
        // Token: 0x06000192 RID: 402 RVA: 0x000081F0 File Offset: 0x000063F0
        protected override AnchorMailboxCacheEntry RefreshCacheEntry()
        {
            ADRawEntry adrawEntry = this.GetADRawEntry();

            if (adrawEntry == null)
            {
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug <UserBasedAnchorMailbox>((long)this.GetHashCode(), "[UserBasedAnchorMailbox::RefreshCacheEntry]: Anchor mailbox {0} has no AD object. Will use random server.", this);
                }
                return(new AnchorMailboxCacheEntry());
            }
            string domainNameFromADRawEntry = UserBasedAnchorMailbox.GetDomainNameFromADRawEntry(adrawEntry);

            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <UserBasedAnchorMailbox, string>((long)this.GetHashCode(), "[UserBasedAnchorMailbox::RefreshCacheEntry]: The domain name of anchor mailbox {0} is {1}.", this, domainNameFromADRawEntry);
            }
            ADObjectId adobjectId = this.GetDatabaseFromADRawEntry(adrawEntry);

            if (adobjectId == null && this.MissingDatabaseHandler != null)
            {
                adobjectId = this.MissingDatabaseHandler(adrawEntry);
            }
            bool isOrganizationMailboxDatabase = false;

            if (adobjectId == null)
            {
                base.RequestContext.Logger.AppendString(3, "-NoDatabase");
                OrganizationId organizationId             = (OrganizationId)adrawEntry[ADObjectSchema.OrganizationId];
                ADUser         defaultOrganizationMailbox = HttpProxyBackEndHelper.GetDefaultOrganizationMailbox(organizationId, ((ADObjectId)adrawEntry[ADObjectSchema.Id]).ToString());
                if (defaultOrganizationMailbox == null || defaultOrganizationMailbox.Database == null)
                {
                    if (Utilities.IsPartnerHostedOnly || GlobalConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MultiTenancy.Enabled)
                    {
                        if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                        {
                            ExTraceGlobals.VerboseTracer.TraceDebug <ADObjectId>((long)this.GetHashCode(), "[UserBasedAnchorMailbox::RefreshCacheEntry]: Cannot find organization mailbox for user {0}. Will use random server.", adrawEntry.Id);
                        }
                        return(new AnchorMailboxCacheEntry
                        {
                            DomainName = domainNameFromADRawEntry
                        });
                    }
                    string text = string.Format("Unable to find organization mailbox for organization {0}", organizationId);
                    if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(3))
                    {
                        ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[UserBasedAnchorMailbox::RefreshCacheEntry]: {0}", text);
                    }
                    throw new HttpProxyException(HttpStatusCode.InternalServerError, 3006, text);
                }
                else
                {
                    adobjectId = defaultOrganizationMailbox.Database;
                    isOrganizationMailboxDatabase = true;
                    if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                    {
                        ExTraceGlobals.VerboseTracer.TraceDebug <ADObjectId, ObjectId, ADObjectId>((long)this.GetHashCode(), "[UserBasedAnchorMailbox::RefreshCacheEntry]: Anchor mailbox user {0} has no mailbox. Will use organization mailbox {1} with database {2}", adrawEntry.Id, defaultOrganizationMailbox.Identity, adobjectId);
                    }
                }
            }
            return(new AnchorMailboxCacheEntry
            {
                Database = adobjectId,
                DomainName = domainNameFromADRawEntry,
                IsOrganizationMailboxDatabase = isOrganizationMailboxDatabase
            });
        }