Beispiel #1
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 #2
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);
        }