internal static bool CanRedirectOutlookClient(string userAgent) { int num; int?num2; int?num3; if (AutodiscoverProxy.TryParseOutlookUserAgent(userAgent, out num, out num2, out num3)) { if (num < 14) { return(true); } if (num == 14 && num2 != null && num2.Value == 0 && num3 != null && num3.Value < 4327) { return(true); } } return(false); }
internal string ProxyingAutodiscoverRequestIfApplicable(ProxyRequestData proxyRequestData, string redirectServer) { if (proxyRequestData == null) { return(null); } ExTraceGlobals.AuthenticationTracer.TraceDebug <string>(0L, "AutodiscoverProxy::ProxyingAutodiscoverRequestIfApplicable. Entry. redirectServer = {0}", redirectServer); string result = null; if (!AutodiscoverProxy.TryProxyAutodiscoverRequest(proxyRequestData, redirectServer, out result)) { ExTraceGlobals.AuthenticationTracer.TraceError <ProxyRequestData, string>(0L, "AutodiscoverProxy::ProxyingAutodiscoverRequestIfApplicable. Cannot proxy this request. proxyRequestData = {0}, redirectServer = {1}", proxyRequestData, redirectServer); } else { proxyRequestData.Response.AddHeader("X-Autodiscover-Proxy", redirectServer); } ExTraceGlobals.AuthenticationTracer.TraceDebug <string>(0L, "AutodiscoverProxy::ProxyingAutodiscoverRequestIfApplicable. Exit. redirectServer = {0}", redirectServer); return(result); }
private static bool TryProxyAutodiscoverRequest(ProxyRequestData proxyRequestData, string redirectServer, out string rawResponse) { ExTraceGlobals.AuthenticationTracer.TraceDebug <string>(0L, "AutodiscoverProxy::TryProxyAutodiscoverRequest. Entrypoint. redirectServer = {0}.", redirectServer); rawResponse = null; if (string.IsNullOrEmpty(redirectServer)) { ExTraceGlobals.AuthenticationTracer.TraceError <string>(0L, "AutodiscoverProxy::TryProxyAutodiscoverRequest. This is an invalid server name. redirectServer = {0}.", redirectServer); return(false); } try { HttpWebRequest httpWebRequest = proxyRequestData.CloneRequest(redirectServer); CertificateValidationManager.SetComponentId(httpWebRequest, "AutodiscoverProxy"); using (WebResponse response = httpWebRequest.GetResponse()) { using (Stream responseStream = response.GetResponseStream()) { rawResponse = AutodiscoverProxy.GetResponse(responseStream); if (rawResponse == null) { ExTraceGlobals.AuthenticationTracer.TraceError <string>(0L, "AutodiscoverProxy::TryProxyAutodiscoverRequest. received wrong number of user response. rawResponse = {0}.", rawResponse); return(false); } ExTraceGlobals.AuthenticationTracer.TraceDebug <string, string>(0L, "AutodiscoverProxy::TryProxyAutodiscoverRequest. Received response for user. redirectServer = {0}, rawResponse = {1}.", redirectServer, rawResponse); } } } catch (LocalizedException arg) { ExTraceGlobals.AuthenticationTracer.TraceError <LocalizedException>(0L, "AutodiscoverProxy::TryProxyAutodiscoverRequest caught with a LocalizedException. LocalizedException = {0}.", arg); return(false); } catch (WebException arg2) { ExTraceGlobals.AuthenticationTracer.TraceError <WebException>(0L, "AutodiscoverProxy::TryProxyAutodiscoverRequest caught with a WebException. WebException = {0}.", arg2); return(false); } return(true); }
internal static bool IsProxyingNeededForClient(bool isAuthenticated, string path, string userAgent, string authorization) { int length; if (authorization != null && (length = authorization.IndexOf(' ')) >= 0) { authorization = authorization.Substring(0, length); } bool enabled = VariantConfiguration.InvariantNoFlightingSnapshot.Autodiscover.RedirectOutlookClient.Enabled; ExTraceGlobals.AuthenticationTracer.TraceDebug(-1L, "AutodiscoverProxy::IsProxyNeededForClient. path = {0}, userAgent = \"{1}\", authorization = \"{2}\", isRedirectOutlookClientEnabled = {3}", new object[] { path, userAgent, authorization, enabled }); return(enabled && !string.IsNullOrEmpty(path) && string.Equals(path, "/autodiscover/autodiscover.xml", StringComparison.OrdinalIgnoreCase) && !(authorization != "Basic") && AutodiscoverProxy.CanRedirectOutlookClient(userAgent)); }
internal static bool IsProxyingNeededForClient(HttpRequest request) { return(AutodiscoverProxy.IsProxyingNeededForClient(request.IsAuthenticated, request.Path, Common.SafeGetUserAgent(request), request.Headers.Get("Authorization"))); }