private static Uri FindRedirectOwaUrlCrossSite(Site targetSite, int expectedMajorVersion, AuthenticationMethod internalAutheticationMethod, AuthenticationMethod externalAuthenticationMethod, BackEndServer backEndServer, out bool isSameAuthMethod, out FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause failureCause) { failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None; isSameAuthMethod = false; bool isSameAuthExternalService = false; OwaService clientExternalService = null; ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 390); string mailboxServerFQDN = backEndServer.Fqdn; new List <OwaService>(); currentServiceTopology.ForEach <OwaService>(delegate(OwaService owaService) { if (ServiceTopology.IsOnSite(owaService, targetSite, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 401) && owaService.ClientAccessType == ClientAccessType.External) { int major = OwaServerVersion.CreateFromVersionNumber(owaService.ServerVersionNumber).Major; if (major == expectedMajorVersion) { bool flag = false; if (owaService.AuthenticationMethod == internalAutheticationMethod || ((internalAutheticationMethod & AuthenticationMethod.Fba) != AuthenticationMethod.None && (owaService.AuthenticationMethod & AuthenticationMethod.Fba) != AuthenticationMethod.None)) { flag = true; if (!isSameAuthExternalService) { clientExternalService = null; isSameAuthExternalService = true; } } if (flag || !isSameAuthExternalService) { if (clientExternalService == null) { clientExternalService = owaService; return; } if (ServiceTopology.CasMbxServicesFirst(owaService, clientExternalService, mailboxServerFQDN, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 432) < 0) { clientExternalService = owaService; } } } } }, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 396); if (clientExternalService != null) { isSameAuthMethod = isSameAuthExternalService; return(clientExternalService.Url); } failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.NoCasFound; return(null); }
public Uri GetCasServerUri(ADObjectId site, int minServerVersionRequested, out int serverVersion) { SortedDictionary <int, List <WebServicesService> > uriVersions = null; serverVersion = 0; try { ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MessageTracking\\ServerCache.cs", "GetCasServerUri", 673); currentServiceTopology.ForEach <WebServicesService>(delegate(WebServicesService service) { if (service.ServerVersionNumber >= minServerVersionRequested && service.Site.Id.Equals(site) && service.ClientAccessType == ClientAccessType.InternalNLBBypass) { if (uriVersions == null) { uriVersions = new SortedDictionary <int, List <WebServicesService> >(); } int key2 = service.ServerVersionNumber >> 16; if (!uriVersions.ContainsKey(key2)) { uriVersions[key2] = new List <WebServicesService>(); } uriVersions[key2].Add(service); } }, "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MessageTracking\\ServerCache.cs", "GetCasServerUri", 674); } catch (ServiceDiscoveryTransientException ex) { TraceWrapper.SearchLibraryTracer.TraceError <ServiceDiscoveryTransientException>(this.GetHashCode(), "Transient exception getting Internal CAS URI: {0}", ex); TrackingTransientException.RaiseETX(ErrorCode.CASUriDiscoveryFailure, site.ToString(), ex.ToString()); } catch (ServiceDiscoveryPermanentException ex2) { TraceWrapper.SearchLibraryTracer.TraceError <ServiceDiscoveryPermanentException>(this.GetHashCode(), "Permanent exception getting Internal CAS URI: {0}", ex2); TrackingFatalException.RaiseETX(ErrorCode.CASUriDiscoveryFailure, site.ToString(), ex2.ToString()); } if (uriVersions != null && uriVersions.Count > 0) { int key = uriVersions.Last <KeyValuePair <int, List <WebServicesService> > >().Key; List <WebServicesService> value = uriVersions.Last <KeyValuePair <int, List <WebServicesService> > >().Value; int index = ServerCache.rand.Next(value.Count); WebServicesService webServicesService = value.ElementAt(index); TraceWrapper.SearchLibraryTracer.TraceDebug <Uri, string>(this.GetHashCode(), "Using CAS URI: {0}, Version {1}", webServicesService.Url, new ServerVersion(webServicesService.ServerVersionNumber).ToString()); serverVersion = webServicesService.ServerVersionNumber; return(webServicesService.Url); } TraceWrapper.SearchLibraryTracer.TraceError <string, string>(this.GetHashCode(), "Failed to find any CAS server in site: {0}, with min version {1}", site.ToString(), new ServerVersion(minServerVersionRequested).ToString()); return(null); }
// Token: 0x06000391 RID: 913 RVA: 0x000161C0 File Offset: 0x000143C0 internal static Uri GetRandomCasExternalServiceUri <T>(ExchangeVersion?requestedVersion, out int serverVersion) where T : HttpService { Dictionary <Uri, int> uriMinimumVersions = null; serverVersion = 0; try { ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\autodisc\\src\\WCF\\Requests\\GetDomainSettingsRequestMessage.cs", "GetRandomCasExternalServiceUri", 101); int minimumVersionNeeded = GetDomainSettingsRequestMessage.GetMinimumServerVersionForExchangeVersion(requestedVersion); currentServiceTopology.ForEach <T>(delegate(T service) { if (service.ServerVersionNumber >= minimumVersionNeeded && service.ClientAccessType == ClientAccessType.External) { if (uriMinimumVersions == null) { uriMinimumVersions = new Dictionary <Uri, int>(10); } int num; if (!uriMinimumVersions.TryGetValue(service.Url, out num) || num > service.ServerVersionNumber) { uriMinimumVersions[service.Url] = service.ServerVersionNumber; } } }, "f:\\15.00.1497\\sources\\dev\\autodisc\\src\\WCF\\Requests\\GetDomainSettingsRequestMessage.cs", "GetRandomCasExternalServiceUri", 105); } catch (ServiceDiscoveryTransientException arg) { ExTraceGlobals.FrameworkTracer.TraceError <ServiceDiscoveryTransientException>(0L, "GetRandomCasExternalServiceUri encountered transient exception: {0}", arg); } catch (ServiceDiscoveryPermanentException arg2) { ExTraceGlobals.FrameworkTracer.TraceError <ServiceDiscoveryPermanentException>(0L, "GetRandomCasExternalServiceUri encountered permanent exception: {0}", arg2); } if (uriMinimumVersions == null) { return(null); } int index = GetDomainSettingsRequestMessage.random.Next(uriMinimumVersions.Count); Uri uri = uriMinimumVersions.Keys.ElementAt(index); serverVersion = uriMinimumVersions[uri]; return(uri); }
private static Uri FindRedirectEcpUrlCrossSite(Site targetSite, int expectedMajorVersion, out FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause failureCause) { failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None; EcpService clientExternalService = null; ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectEcpUrlCrossSite", 470); currentServiceTopology.ForEach <EcpService>(delegate(EcpService ecpService) { if (ServiceTopology.IsOnSite(ecpService, targetSite, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectEcpUrlCrossSite", 476) && ecpService.ClientAccessType == ClientAccessType.External) { int major = OwaServerVersion.CreateFromVersionNumber(ecpService.ServerVersionNumber).Major; if (major == expectedMajorVersion) { clientExternalService = ecpService; } } }, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectEcpUrlCrossSite", 473); if (clientExternalService != null) { return(clientExternalService.Url); } failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.NoCasFound; return(null); }
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: 0x06000556 RID: 1366 RVA: 0x0001D77C File Offset: 0x0001B97C private static Uri FindRedirectOwaUrlOnSiteForMismatchVersion(Site targetSite, int expectedMajorVersion, AuthenticationMethod internalAutheticationMethod, AuthenticationMethod externalAuthenticationMethod, BackEndServer backEndServer, out bool isSameAuthMethod, out FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause failureCause) { failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None; isSameAuthMethod = true; bool isSameAuthInternalService = false; bool isSameAuthExternalService = false; OwaService clientInternalService = null; OwaService clientExternalService = null; string mailboxServerFQDN = backEndServer.Fqdn; ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlOnSiteForMismatchVersion", 578); new List <OwaService>(); currentServiceTopology.ForEach <OwaService>(delegate(OwaService owaService) { if (ServiceTopology.IsOnSite(owaService, targetSite, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlOnSiteForMismatchVersion", 587)) { if (owaService.ClientAccessType == 1) { if (OwaServerVersion.CreateFromVersionNumber(owaService.ServerVersionNumber).Major == expectedMajorVersion) { bool flag = false; if (owaService.AuthenticationMethod == internalAutheticationMethod || ((internalAutheticationMethod & 4) != null && (owaService.AuthenticationMethod & 4) != null)) { flag = true; if (!isSameAuthExternalService) { clientExternalService = null; isSameAuthExternalService = true; } } if (flag || !isSameAuthExternalService) { if (clientExternalService == null) { clientExternalService = owaService; return; } if (ServiceTopology.CasMbxServicesFirst(owaService, clientExternalService, mailboxServerFQDN, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlOnSiteForMismatchVersion", 618) < 0) { clientExternalService = owaService; return; } } } } else if (owaService.ClientAccessType == null && OwaServerVersion.CreateFromVersionNumber(owaService.ServerVersionNumber).Major == expectedMajorVersion && clientExternalService == null) { bool flag = false; if (owaService.AuthenticationMethod == internalAutheticationMethod || ((internalAutheticationMethod & 4) != null && (owaService.AuthenticationMethod & 4) != null)) { flag = true; if (!isSameAuthInternalService) { clientInternalService = null; isSameAuthInternalService = true; } } if (flag || !isSameAuthInternalService) { if (clientInternalService == null) { clientInternalService = owaService; return; } if (ServiceTopology.CasMbxServicesFirst(owaService, clientInternalService, mailboxServerFQDN, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlOnSiteForMismatchVersion", 657) > 0) { clientInternalService = owaService; } } } } }, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlOnSiteForMismatchVersion", 582); if (clientExternalService != null) { isSameAuthMethod = isSameAuthExternalService; return(clientExternalService.Url); } if (clientInternalService != null) { isSameAuthMethod = isSameAuthInternalService; return(clientInternalService.Url); } failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.NoCasFound; return(null); }
// Token: 0x06000230 RID: 560 RVA: 0x0000D4F0 File Offset: 0x0000B6F0 protected override void WriteConfigXml(XmlWriter xmlFragment) { if (base.RequestedRecipient == null) { this.WriteErrorResponse(xmlFragment, "2", Strings.MobileSyncAddressNotFound.ToString(), string.Empty, base.RequestData, null, null); return; } if (base.RequestedRecipient.RecipientType != RecipientType.UserMailbox) { this.WriteErrorResponse(xmlFragment, "9", Strings.MobileSyncBadAddress.ToString(), base.RequestedRecipient.RecipientType.ToString(), base.RequestData, base.RequestedRecipient.DisplayName, base.RequestedRecipient.PrimarySmtpAddress.ToString()); return; } ADUser adUser = base.RequestedRecipient as ADUser; ExchangePrincipal exchangePrincipal = Common.GetExchangePrincipal(adUser); if (exchangePrincipal == null) { this.WriteErrorResponse(xmlFragment, "1", Strings.ActiveDirectoryFailure.ToString(), base.RequestedRecipient.RecipientType.ToString(), base.RequestData, base.RequestedRecipient.DisplayName, base.RequestedRecipient.PrimarySmtpAddress.ToString()); return; } string mobileName = null; string certUrl = null; string certTemplate = null; bool certEnabled = false; VariantConfigurationSnapshot configuration = exchangePrincipal.GetConfiguration(); if (Common.SkipServiceTopologyInDatacenter(configuration)) { Uri datacenterFrontEndEasUrl = FrontEndLocator.GetDatacenterFrontEndEasUrl(); if (datacenterFrontEndEasUrl != null) { mobileName = datacenterFrontEndEasUrl.ToString(); } } else { ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\autodisc\\src\\Providers\\MobileSync\\Web\\MobileSyncProvider.cs", "WriteConfigXml", 376); Site site = currentServiceTopology.GetSite(exchangePrincipal.MailboxInfo.Location.ServerFqdn, "f:\\15.00.1497\\sources\\dev\\autodisc\\src\\Providers\\MobileSync\\Web\\MobileSyncProvider.cs", "WriteConfigXml", 377); SiteCostComparer <MobileSyncService> comparer = new SiteCostComparer <MobileSyncService>(currentServiceTopology, site); MobileSyncService cheapest = null; MobileSyncService cheapestToProxy = null; currentServiceTopology.ForEach <MobileSyncService>(delegate(MobileSyncService service) { if (service.ClientAccessType == ClientAccessType.External) { if (service.ServerVersionNumber == exchangePrincipal.MailboxInfo.Location.ServerVersion && (cheapest == null || comparer.Compare(cheapest, service) > 0)) { cheapest = service; return; } if (cheapestToProxy == null || comparer.Compare(cheapestToProxy, service) > 0) { if (service.ServerVersionNumber > exchangePrincipal.MailboxInfo.Location.ServerVersion) { cheapestToProxy = service; return; } ServerVersion serverVersion = new ServerVersion(exchangePrincipal.MailboxInfo.Location.ServerVersion); ServerVersion serverVersion2 = new ServerVersion(service.ServerVersionNumber); if (serverVersion2.Major >= serverVersion.Major && serverVersion2.Minor >= serverVersion.Minor) { cheapestToProxy = service; } } } }, "f:\\15.00.1497\\sources\\dev\\autodisc\\src\\Providers\\MobileSync\\Web\\MobileSyncProvider.cs", "WriteConfigXml", 388); if (cheapest == null && cheapestToProxy == null) { this.WriteErrorResponse(xmlFragment, "1", Strings.ExternalUrlNotFound.ToString(), base.RequestedRecipient.RecipientType.ToString(), base.RequestData, base.RequestedRecipient.DisplayName, base.RequestedRecipient.PrimarySmtpAddress.ToString()); return; } if (cheapest == null || (cheapestToProxy != null && comparer.Compare(cheapest, cheapestToProxy) > 0)) { cheapest = cheapestToProxy; } mobileName = cheapest.Url.ToString(); certUrl = cheapest.CertificateAuthorityUrl; certTemplate = cheapest.CertEnrollTemplateName; certEnabled = cheapest.IsCertEnrollEnabled; } Common.StartEnvelope(xmlFragment); xmlFragment.WriteStartElement("Response", this.ResponseNs); xmlFragment.WriteElementString("Culture", this.ResponseNs, MobileSyncProvider.defaultCulture); this.WriteUserFragment(xmlFragment, base.RequestedRecipient.DisplayName, base.RequestedRecipient.PrimarySmtpAddress.ToString()); xmlFragment.WriteStartElement("Action", this.ResponseNs); xmlFragment.WriteStartElement("Settings", this.ResponseNs); this.WriteServerFragment(xmlFragment, mobileName, certUrl, certTemplate, certEnabled); xmlFragment.WriteEndElement(); this.WriteMailboxesFragment(xmlFragment, exchangePrincipal); xmlFragment.WriteEndElement(); xmlFragment.WriteEndElement(); Common.EndEnvelope(xmlFragment); Common.EventLog.LogEvent(AutodiscoverEventLogConstants.Tuple_InfoProvConfigurationResponse, Common.PeriodicKey, new object[] { (base.RequestData.LegacyDN == null) ? base.RequestData.EMailAddress : base.RequestData.LegacyDN }); RequestDetailsLoggerBase <RequestDetailsLogger> .Current.AppendGenericInfo("MobileSyncConfigSuccess", base.RequestData.LegacyDN ?? base.RequestData.EMailAddress); }