private bool IsEligibleOabServiceBasedOnVersion(OabService oabService, OABCache.OABCacheEntry oabCacheEntry) { bool result = false; if (oabService != null && !oabService.IsOutOfService && oabService.ServerVersionNumber < Server.E15MinVersion) { result = true; } return(result); }
// Token: 0x06000266 RID: 614 RVA: 0x0000C118 File Offset: 0x0000A318 public OABCache.OABCacheEntry GetOABFromCacheOrAD(Guid exchangeObjectId, string userAcceptedDomain) { OABCache.OABCacheEntry oabcacheEntry = null; if (this.oabTimeoutCache.TryGetValue(exchangeObjectId, ref oabcacheEntry)) { return(oabcacheEntry); } OfflineAddressBook offlineAddressBook = DirectoryHelper.GetConfigurationSessionFromExchangeGuidAndDomain(exchangeObjectId, userAcceptedDomain).FindByExchangeObjectId <OfflineAddressBook>(exchangeObjectId, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\Cache\\OABCache.cs", 115, "GetOABFromCacheOrAD"); if (offlineAddressBook == null) { throw new ADNoSuchObjectException(new LocalizedString(exchangeObjectId.ToString())); } oabcacheEntry = new OABCache.OABCacheEntry(offlineAddressBook); this.oabTimeoutCache.TryInsertAbsolute(exchangeObjectId, oabcacheEntry, OABCache.cacheTimeToLive.Value); return(oabcacheEntry); }
public OABCache.OABCacheEntry GetOABFromCacheOrAD(Guid exchangeObjectId, string userAcceptedDomain) { OABCache.OABCacheEntry oabcacheEntry = null; if (this.oabTimeoutCache.TryGetValue(exchangeObjectId, out oabcacheEntry)) { return(oabcacheEntry); } IConfigurationSession configurationSessionFromDomain = DirectoryHelper.GetConfigurationSessionFromDomain(userAcceptedDomain); OfflineAddressBook offlineAddressBook = configurationSessionFromDomain.FindByExchangeObjectId <OfflineAddressBook>(exchangeObjectId); if (offlineAddressBook == null) { throw new ADNoSuchObjectException(new LocalizedString(exchangeObjectId.ToString())); } oabcacheEntry = new OABCache.OABCacheEntry(offlineAddressBook); this.oabTimeoutCache.TryInsertAbsolute(exchangeObjectId, oabcacheEntry, OABCache.cacheTimeToLive.Value); return(oabcacheEntry); }
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); }
private bool IsEligibleOabServiceBasedOnVersionAndVirtualDirectory(OabService oabService, OABCache.OABCacheEntry oabCacheEntry) { bool result = false; if (oabService != null && !oabService.IsOutOfService && oabService.ServerVersionNumber < Server.E15MinVersion) { foreach (ADObjectId x in oabCacheEntry.VirtualDirectories) { if (ADObjectId.Equals(x, oabService.ADObjectId)) { result = true; break; } } } return(result); }
private AnchorMailbox GetE14CASServer(OABCache.OABCacheEntry oab) { ServiceTopology serviceTopology = ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\OabProxyRequestHandler.cs", "GetE14CASServer", 287); Site currentSite = HttpProxyGlobals.LocalSite.Member; List <OabService> cheapestCASServers = new List <OabService>(); int cheapestSiteConnectionCost = int.MaxValue; OabProxyRequestHandler.IsEligibleOabService isEligibleOabServiceDelegate = null; if (oab.GlobalWebDistributionEnabled) { isEligibleOabServiceDelegate = new OabProxyRequestHandler.IsEligibleOabService(this.IsEligibleOabServiceBasedOnVersion); } else { if (oab.VirtualDirectories == null || oab.VirtualDirectories.Count <= 0) { ExTraceGlobals.VerboseTracer.TraceError(0L, "[OabProxyRequestHandler::ResolveAnchorMailbox] The OAB is distributed neither globally nor to named vdirs; there is no way to retrieve it"); throw new HttpProxyException(HttpStatusCode.InternalServerError, HttpProxySubErrorCode.ServerNotFound, "The OAB is distributed neither globally nor to named vdirs; there is no way to retrieve it"); } isEligibleOabServiceDelegate = new OabProxyRequestHandler.IsEligibleOabService(this.IsEligibleOabServiceBasedOnVersionAndVirtualDirectory); } serviceTopology.ForEach <OabService>(delegate(OabService oabService) { if (isEligibleOabServiceDelegate(oabService, oab)) { int maxValue = int.MaxValue; if (currentSite != null && oabService.Site != null) { serviceTopology.TryGetConnectionCost(currentSite, oabService.Site, out maxValue, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\OabProxyRequestHandler.cs", "GetE14CASServer", 325); } if (maxValue == cheapestSiteConnectionCost) { cheapestCASServers.Add(oabService); return; } if (maxValue < cheapestSiteConnectionCost) { cheapestCASServers.Clear(); cheapestCASServers.Add(oabService); cheapestSiteConnectionCost = maxValue; } } }, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\OabProxyRequestHandler.cs", "GetE14CASServer", 316); if (cheapestCASServers.Count == 0) { ExTraceGlobals.VerboseTracer.TraceError(0L, "[OabProxyRequestHandler::ResolveAnchorMailbox] Could not find a valid downlevel CAS server for this OAB"); throw new HttpProxyException(HttpStatusCode.InternalServerError, HttpProxySubErrorCode.ServerNotFound, "Could not find a valid downlevel CAS server for this OAB"); } OabService oabService2; if (cheapestCASServers.Count == 1) { oabService2 = cheapestCASServers[0]; } else { oabService2 = cheapestCASServers[OabProxyRequestHandler.RandomNumberGenerator.Next(cheapestCASServers.Count)]; } BackEndServer backendServer = new BackEndServer(oabService2.ServerFullyQualifiedDomainName, oabService2.ServerVersionNumber); return(new ServerInfoAnchorMailbox(backendServer, this)); }
// 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); }