private void MessageHeaderComplete(IRequest req) { UpdateTextBox(req.Result.Results); UpdateLabel(""); MessageHeaderProcessor mhp = req.GetProcessorAsType <MessageHeaderProcessor>(); StringBuilder sb = new StringBuilder(); sb.AppendFormat("To Count: {0}{1}", mhp.Message.ToContacts.Length, Environment.NewLine); sb.AppendFormat("From Count: {0}{1}", mhp.Message.FromContacts.Length, Environment.NewLine); //MessageBox.Show(sb.ToString()); }
private void ShowMessageGroup(IMessage[] msgList, int startNum) { //*UID(5) From(15) Subject(30) Date ColorConsole.WriteLine("\n^15:00 UID From Subject Date"); ColorConsole.Write("^08:00{0}", new string('-', Console.BufferWidth)); int msgCount = 0; int blockSize = MSGS_PER_BLOCK; for (int i = startNum; i < startNum + MSGS_PER_BLOCK; i++) { if (i == msgList.Length) { int maxGroups = msgList.Length / MSGS_PER_BLOCK; blockSize = msgList.Length - (maxGroups * MSGS_PER_BLOCK); break; } IMessage msg = msgList[i]; if (!msg.HeaderLoaded) { bool headerLoaded = false; Shell.Client.RequestManager.SubmitRequest(new MessageFlagRequest(msg, delegate { Shell.Client.RequestManager.SubmitRequest(new MessageHeaderRequest(msg, delegate(IRequest req) { //headerLoaded = true; MessageHeaderProcessor mhp = req.GetProcessorAsType <MessageHeaderProcessor>(); PrintMessage(mhp.Message); msgCount++; }), false); }), false); } else { PrintMessage(msg); msgCount++; } } while (msgCount < blockSize) { Thread.Sleep(1); } }
// Token: 0x06000595 RID: 1429 RVA: 0x00010BDC File Offset: 0x0000EDDC internal static CallContext CreateCallContext(Message request, MessageHeaderProcessor headerProcessor, bool duplicatedActionDetectionEnabled, string owaUserContextKey = "") { ExAssert.RetailAssert(request != null, "request should not be null"); ExAssert.RetailAssert(HttpContext.Current != null, "HttpContext.Current should not be null"); MessageHeaderProcessor headerProcessor2 = headerProcessor ?? new JsonMessageHeaderProcessor(); RequestContext requestContext = RequestContext.Get(HttpContext.Current); UserContext userContext = requestContext.UserContext as UserContext; bool flag = false; CallContext callContext; if (userContext != null && userContext.FeaturesManager.ClientServerSettings.OWAPLTPerf.Enabled && HttpContext.Current.User.Identity is SidBasedIdentity && !userContext.IsExplicitLogon) { Trace coreCallTracer = ExTraceGlobals.CoreCallTracer; long id = 0L; string formatString = "[CallContextUtilities::CreateAndSetCallContext] Using CreateFromInternalRequestContext to create CallContext. UserContextKey:{0}, primarySmtpAddress:{1}"; string arg = (userContext.Key != null) ? userContext.Key.ToString() : "<null>"; string arg2; if (userContext.LogonIdentity != null) { SmtpAddress primarySmtpAddress = userContext.LogonIdentity.PrimarySmtpAddress; arg2 = userContext.LogonIdentity.PrimarySmtpAddress.ToString(); } else { arg2 = "<null>"; } coreCallTracer.TraceDebug <string, string>(id, formatString, arg, arg2); callContext = CallContext.CreateFromInternalRequestContext(headerProcessor2, request, duplicatedActionDetectionEnabled, (IEWSPartnerRequestContext)requestContext.UserContext); flag = true; } else { IMailboxContext userContext2 = requestContext.UserContext; Trace coreCallTracer2 = ExTraceGlobals.CoreCallTracer; long id2 = 0L; string formatString2 = "[CallContextUtilities::CreateAndSetCallContext] Using CreateFromRequest to create CallContext. UserContextKey:{0}, primarySmtpAddress:{1}"; string arg3 = (userContext2 != null && userContext2.Key != null) ? userContext2.Key.ToString() : "<null>"; string arg4; if (userContext2 != null && userContext2.LogonIdentity != null) { SmtpAddress primarySmtpAddress2 = userContext2.LogonIdentity.PrimarySmtpAddress; arg4 = userContext2.LogonIdentity.PrimarySmtpAddress.ToString(); } else { arg4 = "<null>"; } coreCallTracer2.TraceDebug <string, string>(id2, formatString2, arg3, arg4); callContext = CallContext.CreateFromRequest(headerProcessor2, request, duplicatedActionDetectionEnabled); } callContext.IsOwa = true; callContext.OwaUserContextKey = owaUserContextKey; try { if (callContext.AccessingADUser != null && callContext.AccessingPrincipal != null && !callContext.AccessingADUser.ObjectId.Equals(callContext.AccessingPrincipal.ObjectId)) { throw new InvalidOperationException(string.Format("Invalid CallContext created from {0} due to mismatch user. AccessingADUser.LegDN = {1} and AccessingPrincipal.LegDN = {2}", flag ? "Internal Request" : "Request", callContext.AccessingADUser.LegacyExchangeDN, callContext.AccessingPrincipal.LegacyDn)); } } catch (InvalidOperationException ex) { ExTraceGlobals.CoreCallTracer.TraceError(0L, ex.Message); callContext.ProtocolLog.AppendGenericError("InvalidCC", ex.Message); StringBuilder stringBuilder = new StringBuilder(500); NameValueCollection headers = HttpContext.Current.Request.Headers; if (headers != null) { foreach (string text in headers.AllKeys) { string arg5 = headers[text] ?? string.Empty; stringBuilder.AppendFormat("{0}={1};", text, arg5); } } stringBuilder.Append("ADUser="******";"); stringBuilder.Append("ExchangePrincipal=" + callContext.AccessingPrincipal.LegacyDn + ";"); ExWatson.SendReport(ex, ReportOptions.None, stringBuilder.ToString()); } callContext.ADRecipientSessionContext.ExcludeInactiveMailboxInADRecipientSession(); return(callContext); }
private object InternalAfterReceiveRequest(ref Message request, RequestDetailsLogger logger) { try { Globals.UpdateErrorTracingConfiguration(); IActivityScope activityScope = OwaApplication.GetRequestDetailsLogger.ActivityScope; HttpRequestMessageProperty httpRequestMessageProperty = (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name]; string value = httpRequestMessageProperty.Headers[OWADispatchOperationSelector.Action]; activityScope.SetProperty(ExtensibleLoggerMetadata.EventId, value); string value2 = httpRequestMessageProperty.Headers["X-OWA-ClientBuildVersion"]; if (!string.IsNullOrEmpty(value2)) { activityScope.SetProperty(OwaServerLogger.LoggerData.ClientBuildVersion, value2); } else { activityScope.SetProperty(OwaServerLogger.LoggerData.ClientBuildVersion, "NA"); } string value3 = httpRequestMessageProperty.Headers["X-EWS-TargetVersion"]; if (!string.IsNullOrEmpty(value3)) { activityScope.SetProperty(OwaServerLogger.LoggerData.RequestVersion, value3); } else { activityScope.SetProperty(OwaServerLogger.LoggerData.RequestVersion, "NA"); } JsonMessageHeaderProcessor jsonMessageHeaderProcessor = new JsonMessageHeaderProcessor(); string methodName = OWAMessageInspector.GetMethodName(request); bool flag = OWAMessageInspector.RequestNeedsHeaderProcessing(methodName); bool flag2 = OWAMessageInspector.RequestNeedsQueryStringProcessing(methodName); bool flag3 = OWAMessageInspector.RequestNeedsHttpHeaderProcessing(methodName); if (flag || flag2 || flag3) { using (MessageBuffer messageBuffer = request.CreateBufferedCopy(int.MaxValue)) { Message request2 = messageBuffer.CreateMessage(); if (flag) { jsonMessageHeaderProcessor.ProcessMessageHeaders(request2); jsonMessageHeaderProcessor.ProcessEwsVersionFromHttpHeaders(request); } else if (flag2) { jsonMessageHeaderProcessor.ProcessMessageHeadersFromQueryString(request2); } else if (flag3) { jsonMessageHeaderProcessor.ProcessHttpHeaders(request, ExchangeVersion.Exchange2013); } request = messageBuffer.CreateMessage(); } } request.Properties["MessageHeaderProcessor"] = jsonMessageHeaderProcessor; request.Properties["ConnectionCostType"] = 0; WebMethodEntry jsonWebMethodEntry; if (!OWAMessageInspector.MethodNameToWebMethodEntryMap.Member.TryGetValue(methodName, out jsonWebMethodEntry)) { jsonWebMethodEntry = WebMethodEntry.JsonWebMethodEntry; } request.Properties["WebMethodEntry"] = jsonWebMethodEntry; MessageHeaderProcessor messageHeaderProcessor = (MessageHeaderProcessor)request.Properties["MessageHeaderProcessor"]; messageHeaderProcessor.MarkMessageHeaderAsUnderstoodIfExists(request, "RequestServerVersion", "http://schemas.microsoft.com/exchange/services/2006/types"); RequestDetailsLogger.LogEvent(logger, OwaServerLogger.LoggerData.CallContextInitBegin); Message requestRef = request; CallContext callContext = OwaApplication.GetRequestDetailsLogger.TrackLatency <CallContext>(ServiceLatencyMetadata.CallContextInitLatency, () => CallContextUtilities.CreateCallContext(requestRef, messageHeaderProcessor, true, "")); RequestDetailsLogger.LogEvent(logger, OwaServerLogger.LoggerData.CallContextInitEnd); callContext.ProtocolLog.Set(OwaServerLogger.LoggerData.IsMowaClient, OfflineClientRequestUtilities.IsRequestFromMOWAClient(callContext.HttpContext.Request, callContext.HttpContext.Request.UserAgent) ? 1 : 0); bool?flag4 = new bool?(OfflineClientRequestUtilities.IsRequestFromOfflineClient(callContext.HttpContext.Request)); if (flag4 != null) { callContext.ProtocolLog.Set(OwaServerLogger.LoggerData.IsOfflineEnabled, flag4.Value ? 1 : 0); } callContext.OwaExplicitLogonUser = UserContextUtilities.GetExplicitLogonUser(HttpContext.Current); if (string.IsNullOrEmpty(callContext.OwaExplicitLogonUser)) { OWAMessageInspector.CheckThatUserProvisionedDevice(methodName, callContext); OWAMessageInspector.CheckMowaRemoteWipe(methodName, callContext); OWAMessageInspector.CheckClientVersion(callContext); OWAMessageInspector.CheckMowaDisabled(callContext); OWAMessageInspector.CheckMobileDevicePolicyIsCorrect(methodName, callContext); } OWAMessageInspector.MarkResponseNonCacheable(methodName); callContext.WorkloadType = WorkloadType.Owa; callContext.UsingWcfDispatcher = true; callContext.ProtocolLog.Set(OwaServerLogger.LoggerData.UsingWcfHttpHandler, 1); if (ExchangeVersion.Current == ExchangeVersion.Exchange2007) { ExchangeVersion.Current = ExchangeVersion.Exchange2013; } if (OWAMessageInspector.ShouldCreateUserContext(callContext)) { UserContext userContext = UserContextManager.GetMailboxContext(callContext.HttpContext, callContext.EffectiveCaller, true) as UserContext; if (userContext != null) { callContext.OwaCulture = userContext.UserCulture; if (userContext.FeaturesManager != null) { callContext.FeaturesManager = userContext.FeaturesManager; if (userContext.FeaturesManager.ServerSettings.OwaMailboxSessionCloning.Enabled) { callContext.OwaUserContextKey = userContext.Key.ToString(); } } } } } catch (LocalizedException ex) { Microsoft.Exchange.Diagnostics.Components.Services.ExTraceGlobals.CommonAlgorithmTracer.TraceError <string, string>((long)this.GetHashCode(), "[OWAMessageInspector::AfterReceiveRequest] Caught localized exception trying to create callcontext. Class: {0}, Message: {1}", ex.GetType().FullName, ex.Message); OwaServerTraceLogger.AppendToLog(new TraceLogEvent("OWAMessageInspector", null, "InternalAfterReceiveRequest", string.Format("OwaServiceFaultException_InnerException - {0}", ex))); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeLogRequestException(OwaApplication.GetRequestDetailsLogger, ex, "OwaServiceFaultException_InnerException"); throw OwaFaultExceptionUtilities.CreateFault(ex); } return(null); }