public TargetCalculationCallbackBeacon(AnchoredRoutingTarget anchoredRoutingTarget)
 {
     if (anchoredRoutingTarget == null)
     {
         throw new ArgumentNullException("anchoredRoutingTarget");
     }
     this.AnchoredRoutingTarget = anchoredRoutingTarget;
     this.AnchorMailbox         = this.AnchoredRoutingTarget.AnchorMailbox;
     this.State = TargetCalculationCallbackState.TargetResolved;
 }
Ejemplo n.º 2
0
        // Token: 0x060002CC RID: 716 RVA: 0x0000E390 File Offset: 0x0000C590
        public void TraceProxyTarget(AnchoredRoutingTarget anchor)
        {
            if (PfdTracer.IsTraceDisabled)
            {
                return;
            }
            string s = string.Format("{0}: {1}: {2}", this.traceContext, "AnchoredRoutingTarget", anchor.ToString());

            this.Write(s);
        }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }