internal CallContext(HttpContext httpContext, UserCollection users, HashSet <UserConfigurationSettingName> requestedSettings, ExchangeServerVersion?requestedVersion, UserSettingErrorCollection settingErrors, GetUserSettingsResponse response) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } if (httpContext.Request == null) { throw new ArgumentException("The specified HTTP context has the Request property null", "httpContext"); } this.Users = users; this.RequestedSettings = requestedSettings; this.RequestedVersion = requestedVersion; this.SettingErrors = settingErrors; this.Response = response; this.UseClientCertificateAuthentication = Common.CheckClientCertificate(httpContext.Request); this.UserAgent = httpContext.Request.UserAgent; this.UserAuthType = httpContext.Request.ServerVariables["AUTH_TYPE"]; this.CallerCapabilities = CallerRequestedCapabilities.GetInstance(httpContext); }
public Message LegacyAction(Message input) { Message reply = null; Common.SendWatsonReportOnUnhandledException(delegate { RequestData requestData = null; object obj = null; HttpContext httpContext = HttpContext.Current; if (input.Properties.TryGetValue("RequestData", out obj)) { requestData = (RequestData)obj; } else { bool useClientCertificateAuthentication = Common.CheckClientCertificate(httpContext.Request); requestData = new RequestData(null, useClientCertificateAuthentication, CallerRequestedCapabilities.GetInstance(httpContext)); input.Properties["RequestData"] = requestData; input.Properties["ParseSuccess"] = false; } string userAgent = Common.SafeGetUserAgent(httpContext.Request); ProxyAddress proxyAddress; if (VariantConfiguration.InvariantNoFlightingSnapshot.Autodiscover.RedirectOutlookClient.Enabled && AutodiscoverProxy.CanRedirectOutlookClient(userAgent) && !string.IsNullOrEmpty(requestData.EMailAddress) && SmtpProxyAddress.TryDeencapsulate(requestData.EMailAddress, out proxyAddress)) { requestData.EMailAddress = proxyAddress.AddressString; } LegacyBodyWriter bodyWriter; RequestDetailsLoggerBase <RequestDetailsLogger> .Current.TrackLatency(ServiceLatencyMetadata.CoreExecutionLatency, delegate() { if (!HttpContext.Current.Request.IsAuthenticated) { requestData.Clear(); input.Properties["ParseSuccess"] = false; bodyWriter = new LegacyBodyWriter(input, HttpContext.Current); reply = Message.CreateMessage(MessageVersion.None, "*", bodyWriter); HttpResponseMessageProperty httpResponseMessageProperty = new HttpResponseMessageProperty(); httpResponseMessageProperty.StatusCode = HttpStatusCode.Unauthorized; reply.Properties.Add(HttpResponseMessageProperty.Name, httpResponseMessageProperty); return; } bodyWriter = new LegacyBodyWriter(input, HttpContext.Current); reply = Message.CreateMessage(MessageVersion.None, "*", bodyWriter); }); }); return(reply); }
// Token: 0x060002D4 RID: 724 RVA: 0x00012B44 File Offset: 0x00010D44 public LegacyBodyWriter(Message input, HttpContext context) : base(true) { IPrincipal user = context.User; this.parseSuccess = false; object obj; if (!input.Properties.TryGetValue("RequestData", out obj)) { bool useClientCertificateAuthentication = Common.CheckClientCertificate(context.Request); this.requestData = new RequestData(user, useClientCertificateAuthentication, CallerRequestedCapabilities.GetInstance(context)); } else { this.requestData = (RequestData)obj; this.requestData.User = user; } this.requestData.UserAgent = Common.SafeGetUserAgent(context.Request); if (input.Properties.TryGetValue("ParseSuccess", out obj)) { this.parseSuccess = (bool)obj; } if (input.Properties.TryGetValue("DebugData", out obj)) { this.debugData = (string)obj; } }
private bool ValidateAndParseRequest(Stream stream, out RequestData requestData) { Stream stream2 = null; bool useClientCertificateAuthentication = Common.CheckClientCertificate(HttpContext.Current.Request); requestData = new RequestData(null, useClientCertificateAuthentication, CallerRequestedCapabilities.GetInstance(HttpContext.Current)); string a = string.Empty; XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); xmlReaderSettings.ValidationType = ValidationType.Schema; xmlReaderSettings.CheckCharacters = true; xmlReaderSettings.IgnoreWhitespace = true; xmlReaderSettings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings; xmlReaderSettings.ConformanceLevel = ConformanceLevel.Document; xmlReaderSettings.Schemas = ProvidersTable.RequestSchemaSet; xmlReaderSettings.ValidationEventHandler += this.ValidationEventHandler; requestData.UserAuthType = HttpContext.Current.Request.ServerVariables["AUTH_TYPE"]; string text = HttpContext.Current.Request.Headers.Get("X-MapiHttpCapability"); int num; if (string.IsNullOrEmpty(text) || !int.TryParse(text, out num) || num < 0) { num = 0; } requestData.MapiHttpVersion = num; if (!requestData.CallerCapabilities.CanFollowRedirect) { requestData.ProxyRequestData = new ProxyRequestData(HttpContext.Current.Request, HttpContext.Current.Response, ref stream); stream2 = requestData.ProxyRequestData.RequestStream; stream = stream2; } this.validationError = false; try { XmlReader xmlReader = XmlReader.Create(stream, xmlReaderSettings); while (!xmlReader.EOF && !this.validationError) { switch (xmlReader.NodeType) { case XmlNodeType.Element: a = xmlReader.LocalName; while (xmlReader.MoveToNextAttribute()) { if (xmlReader.Name == "xmlns") { requestData.RequestSchemas.Add(xmlReader.Value); } } break; case XmlNodeType.Text: if (xmlReader.HasValue) { if (a == "AcceptableResponseSchema") { requestData.ResponseSchemas.Add(xmlReader.Value); } else if (a == "EMailAddress") { requestData.EMailAddress = xmlReader.Value; } else if (a == "LegacyDN") { requestData.LegacyDN = xmlReader.Value; } } break; } xmlReader.Read(); } } catch (XmlException ex) { ExTraceGlobals.FrameworkTracer.TraceError <string, int, int>((long)this.GetHashCode(), "[ValidateAndParseRequest()] Message=\"{0}\";LineNumber=\"{1}\";LinePosition=\"{2}\"", ex.Message, ex.LineNumber, ex.LinePosition); Common.EventLog.LogEvent(AutodiscoverEventLogConstants.Tuple_WarnCoreValidationException, Common.PeriodicKey, new object[] { ex.Message }); return(false); } finally { if (stream2 != null) { stream2.Dispose(); } } if (this.validationError) { return(false); } if (string.IsNullOrEmpty(requestData.EMailAddress) && string.IsNullOrEmpty(requestData.LegacyDN)) { ExTraceGlobals.FrameworkTracer.TraceError <string, string>((long)this.GetHashCode(), "[ValidateAndParseRequest()] 'Both \"{0}\" and \"{1}\" are empty'", "EMailAddress", "LegacyDN"); Common.EventLog.LogEvent(AutodiscoverEventLogConstants.Tuple_WarnCoreElementsAreEmpty, Common.PeriodicKey, new object[] { "EMailAddress,LegacyDN" }); } else { if (requestData.ResponseSchemas.Count != 0 && !string.IsNullOrEmpty(requestData.ResponseSchemas[0])) { return(true); } ExTraceGlobals.FrameworkTracer.TraceError <string>((long)this.GetHashCode(), "[ValidateAndParseRequest()] 'Element \"{0}\" is empty'", "AcceptableResponseSchema"); Common.EventLog.LogEvent(AutodiscoverEventLogConstants.Tuple_WarnCoreElementIsEmpty, Common.PeriodicKey, new object[] { "AcceptableResponseSchema" }); } return(false); }
// Token: 0x060002DE RID: 734 RVA: 0x000133C8 File Offset: 0x000115C8 private void GenerateErrorResponse(HttpContext context) { HttpResponse response = context.Response; response.ContentType = "text/xml; charset=utf-8"; using (TextWriter output = response.Output) { XmlWriter xmlFragment = XmlWriter.Create(output, new XmlWriterSettings { Indent = true, IndentChars = " ", ConformanceLevel = ConformanceLevel.Document }); bool useClientCertificateAuthentication = false; RequestData requestData = new RequestData(null, useClientCertificateAuthentication, CallerRequestedCapabilities.GetInstance(context)); Common.GenerateErrorResponseDontLog(xmlFragment, "http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006", "600", Strings.InvalidRequest, string.Empty, requestData, base.GetType().AssemblyQualifiedName); } }