Ejemplo n.º 1
0
        // Token: 0x060011C1 RID: 4545 RVA: 0x00044734 File Offset: 0x00042934
        private void OnBeginRequest(object sender, EventArgs e)
        {
            if (!Globals.IsInitialized)
            {
                return;
            }
            HttpApplication httpApplication         = (HttpApplication)sender;
            HttpContext     context                 = httpApplication.Context;
            string          cookieValueAndSetIfNull = ClientIdCookie.GetCookieValueAndSetIfNull(context);

            try
            {
                context.Response.AppendToLog(string.Format("&{0}={1}", "ClientId", cookieValueAndSetIfNull));
            }
            catch (Exception ex)
            {
                ExTraceGlobals.ExceptionTracer.TraceError((long)this.GetHashCode(), ex.Message);
            }
            context.Request.Headers["X-BackEnd-Begin"] = ExDateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fff");
            httpApplication.Context.Response.Headers.Set("X-Content-Type-Options", "nosniff");
            RequestContext requestContext = RequestContext.Create(context);

            requestContext.Set(context);
            ExTraceGlobals.RequestTracer.TraceDebug <string, string>((long)requestContext.GetHashCode(), "Request: {0} {1}", context.Request.HttpMethod, context.Request.Url.LocalPath);
        }
Ejemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            string      userContextId           = Plt1WebHandler.GetUserContextId(context);
            bool        isMowa                  = OfflineClientRequestUtilities.IsRequestFromMOWAClient(context.Request, context.Request.UserAgent);
            HttpRequest request                 = context.Request;
            string      clientAddressWithoutPII = this.GetClientAddressWithoutPII(request);
            UserAgent   userAgent               = OwaUserAgentUtilities.CreateUserAgentWithLayoutOverride(context);
            string      userName                = string.Empty;
            string      cookieValueAndSetIfNull = ClientIdCookie.GetCookieValueAndSetIfNull(context);
            UserContext userContext             = UserContextManager.GetUserContext(context, false);

            if (userContext != null && userContext.LogonIdentity != null)
            {
                SmtpAddress primarySmtpAddress = userContext.LogonIdentity.PrimarySmtpAddress;
                userName = userContext.LogonIdentity.PrimarySmtpAddress.ToString();
            }
            if (Plt1WebHandler.IsPlt1PerformanceRequest(request))
            {
                string text = "";
                if (context.Request.HttpMethod == "POST")
                {
                    using (StreamReader streamReader = new StreamReader(context.Request.InputStream))
                    {
                        text = streamReader.ReadToEnd();
                        context.Response.AppendToLog(text);
                    }
                }
                string clientVersion = context.Request.QueryString.Get("cver") ?? string.Empty;
                Uri    uri;
                string refererQueryString = request.TryParseUrlReferrer(out uri) ? uri.Query : "noRefUrl";
                Dictionary <string, string> dictionary  = new Dictionary <string, string>();
                Dictionary <string, string> dictionary2 = new Dictionary <string, string>();
                Plt1WebHandler.GetPlt1PerformanceEventData(userAgent, refererQueryString, request.QueryString, text, dictionary, dictionary2);
                Plt1WebHandler.AddClientLoadTimeDataPoint(dictionary, dictionary2, userContextId, clientAddressWithoutPII, clientVersion, isMowa, userName, userContext, cookieValueAndSetIfNull);
                if (dictionary2.Count > 0 && dictionary.ContainsKey("msg") && dictionary["msg"].Contains("success"))
                {
                    Plt1WebHandler.AddCalculatedClientLoadTimeDataPoint(dictionary, dictionary2, userContextId, clientAddressWithoutPII, clientVersion, isMowa, userName, cookieValueAndSetIfNull);
                }
                if (userContext != null && userContext.FeaturesManager != null && userContext.FeaturesManager.ServerSettings.OwaServerLogonActivityLogging.Enabled)
                {
                    this.AddtoActivityLog(userContext, dictionary, userName, clientAddressWithoutPII, userAgent.RawString);
                }
            }
            else
            {
                string         clientVersion2  = context.Request.QueryString.Get("v") ?? string.Empty;
                ClientLogEvent plt1AccessEvent = Plt1WebHandler.GetPlt1AccessEvent(userContextId, request.UserAgent, clientAddressWithoutPII, clientVersion2, isMowa, cookieValueAndSetIfNull);
                OwaClientLogger.AppendToLog(plt1AccessEvent);
            }
            Plt1WebHandler.SetResponseHeaders(context.Response);
            Plt1WebHandler.WriteImage(context.Response);
        }
Ejemplo n.º 3
0
        private IDictionary <DatapointConsumer, LogDatapoint.ClientLogEventList> TriageAndConvertDatapoints(UserContext userContext, Datapoint header, InstrumentationSettings settings, out int totalDatapointSize)
        {
            string            userContextId           = this.GetUserContextId();
            string            clientAddress           = this.GetClientAddress();
            string            userName                = this.isOwa ? base.CallContext.GetEffectiveAccessingSmtpAddress() : "ExternalUser";
            string            cookieValueAndSetIfNull = ClientIdCookie.GetCookieValueAndSetIfNull(HttpContext.Current);
            ClientLogEvent    header2          = new ClientLogEvent(header, userContextId, clientAddress, userName, this.serverVersion, base.CallContext.IsMowa, cookieValueAndSetIfNull);
            DatapointConsumer enabledConsumers = this.GetEnabledConsumers(settings);

            totalDatapointSize = 0;
            LogDatapoint.ClientLogEventList clientLogEventList  = new LogDatapoint.ClientLogEventList(DatapointConsumer.Analytics, enabledConsumers, header2);
            LogDatapoint.ClientLogEventList clientLogEventList2 = new LogDatapoint.ClientLogEventList(DatapointConsumer.Diagnostics, enabledConsumers, header2);
            LogDatapoint.ClientLogEventList clientLogEventList3 = new LogDatapoint.ClientLogEventList(DatapointConsumer.Inference, enabledConsumers, null);
            LogDatapoint.ClientLogEventList clientLogEventList4 = new LogDatapoint.ClientLogEventList(DatapointConsumer.Watson, enabledConsumers, null);
            int num = 0;

            if (userContext != null && this.datapoints[0].Id == "SessionInfo")
            {
                num = 1;
                Datapoint      datapoint      = this.datapoints[0];
                ClientLogEvent clientLogEvent = new ClientLogEvent(datapoint, userContextId, clientAddress, userName, this.serverVersion, base.CallContext.IsMowa, cookieValueAndSetIfNull);
                userContext.LogEventCommonData.UpdateClientData(clientLogEvent.DatapointProperties);
                this.clientVersion = userContext.LogEventCommonData.ClientBuild;
                clientLogEvent.UpdateTenantInfo(userContext);
                clientLogEvent.UpdateNetid(userContext);
                clientLogEvent.UpdateMailboxGuid(userContext.ExchangePrincipal);
                clientLogEvent.UpdateDatabaseInfo(userContext);
                clientLogEvent.UpdateFlightInfo(userContext.LogEventCommonData);
                clientLogEvent.UpdatePassThroughProxyInfo(this.isFromPassThroughProxy);
                clientLogEvent.UpdateUserAgent(userContext.UserAgent);
                clientLogEventList.CheckAndAdd(clientLogEvent);
                clientLogEventList3.CheckAndAdd(clientLogEvent);
                clientLogEventList2.CheckAndAdd(clientLogEvent);
                clientLogEventList4.CheckAndAdd(clientLogEvent);
            }
            for (int i = num; i < this.datapoints.Length; i++)
            {
                Datapoint datapoint2 = this.datapoints[i];
                totalDatapointSize += datapoint2.Size;
                if ((enabledConsumers & datapoint2.Consumers) != DatapointConsumer.None)
                {
                    ClientLogEvent clientLogEvent2 = new ClientLogEvent(datapoint2, userContextId, clientAddress, userName, this.serverVersion, base.CallContext.IsMowa, cookieValueAndSetIfNull);
                    if (userContext != null)
                    {
                        clientLogEvent2.UpdateClientBuildVersion(userContext.LogEventCommonData);
                        string id;
                        if (clientLogEventList.CheckAndAdd(clientLogEvent2) && (id = datapoint2.Id) != null)
                        {
                            if (< PrivateImplementationDetails > { 38B691CF - 9E72 - 4F 22 - A560 - A7F126C51047 }.$$method0x6001a88 - 1 == null)
Ejemplo n.º 4
0
        private void OnBeginRequest(object sender, EventArgs e)
        {
            HttpApplication httpApplication = (HttpApplication)sender;
            HttpContext     httpContext     = httpApplication.Context;

            Diagnostics.SendWatsonReportOnUnhandledException(delegate()
            {
                LatencyTracker latencyTracker = new LatencyTracker();
                latencyTracker.StartTracking(LatencyTrackerKey.ProxyModuleLatency, false);
                AspNetHelper.AddTimestampHeaderIfNecessary(httpContext.Request.Headers, "X-FrontEnd-Begin");
                if (Microsoft.Exchange.Diagnostics.Components.HttpProxy.ExTraceGlobals.VerboseTracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    Microsoft.Exchange.Diagnostics.Components.HttpProxy.ExTraceGlobals.VerboseTracer.TraceDebug <string, Uri, int>((long)this.GetHashCode(), "[ProxyModule::OnBeginRequest]: Method {0}; Url {1}; Context {2};", httpContext.Request.HttpMethod, httpContext.Request.Url, httpContext.GetHashCode());
                }
                if (HealthCheckResponder.Instance.IsHealthCheckRequest(httpContext))
                {
                    HealthCheckResponder.Instance.CheckHealthStateAndRespond(httpContext);
                    return;
                }
                RequestDetailsLogger requestDetailsLogger = RequestDetailsLoggerBase <RequestDetailsLogger> .InitializeRequestLogger();
                requestDetailsLogger.LogCurrentTime("BeginRequest");
                httpContext.Items[Constants.TraceContextKey] = httpContext.GetHashCode();
                httpContext.Items[Constants.LatencyTrackerContextKeyName] = latencyTracker;
                requestDetailsLogger.ActivityScope.UpdateFromMessage(httpContext.Request);
                requestDetailsLogger.ActivityScope.SerializeTo(httpContext.Response);
                RequestDetailsLoggerBase <RequestDetailsLogger> .SetCurrent(httpContext, requestDetailsLogger);
                httpContext.Items[typeof(ActivityScope)] = requestDetailsLogger.ActivityScope;
                httpContext.Items[Constants.RequestIdHttpContextKeyName] = requestDetailsLogger.ActivityScope.ActivityId;
                RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, HttpProxyMetadata.Protocol, HttpProxyGlobals.ProtocolType);
                requestDetailsLogger.SafeLogUriData(httpContext.Request.Url);
                RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, ServiceCommonMetadata.HttpMethod, httpContext.Request.HttpMethod);
                string requestCorrelationId = AspNetHelper.GetRequestCorrelationId(httpContext);
                RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(requestDetailsLogger, "CorrelationID", requestCorrelationId);
                httpContext.Response.AppendToLog(Constants.CorrelationIdKeyForIISLogs + requestCorrelationId + ";");
                string cookieValueAndSetIfNull = ClientIdCookie.GetCookieValueAndSetIfNull(httpContext);
                httpContext.Response.AppendToLog(string.Format("&{0}={1}", "ClientId", cookieValueAndSetIfNull));
                UrlUtilities.SaveOriginalRequestHostSchemePortToContext(httpContext);
                try
                {
                    this.OnBeginRequestInternal(httpApplication);
                }
                catch (Exception ex)
                {
                    RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericError(requestDetailsLogger, "OnBeginRequestInternal", ex.ToString());
                    requestDetailsLogger.AsyncCommit(false);
                    throw;
                }
            }, new Diagnostics.LastChanceExceptionHandler(RequestDetailsLogger.LastChanceExceptionHandler));
        }
Ejemplo n.º 5
0
        protected void CompileDiagnosticInfo()
        {
            this.renderDiagnosticInfo = false;
            StringBuilder stringBuilder = new StringBuilder();

            if (HttpContext.Current.Request.Cookies["ClientId"] != null)
            {
                this.renderDiagnosticInfo = true;
                stringBuilder.Append("X-ClientId: ");
                string value = HttpContext.Current.Request.Cookies["ClientId"].Value;
                string text  = ClientIdCookie.ParseToPrintableString(value);
                stringBuilder.Append(text.ToUpperInvariant());
                stringBuilder.Append("\n");
            }
            if (!string.IsNullOrWhiteSpace(HttpContext.Current.Request.QueryString["owaError"]))
            {
                this.renderDiagnosticInfo = true;
                stringBuilder.Append("X-OWA-Error: ");
                stringBuilder.Append(HttpContext.Current.Request.QueryString["owaError"]);
                stringBuilder.Append("\n");
            }
            if (!string.IsNullOrWhiteSpace(HttpContext.Current.Request.QueryString["authError"]))
            {
                this.renderDiagnosticInfo = true;
                stringBuilder.Append("X-Auth-Error: ");
                stringBuilder.Append(HttpContext.Current.Request.QueryString["authError"]);
                stringBuilder.Append("\n");
            }
            if (!string.IsNullOrWhiteSpace(HttpContext.Current.Request.QueryString["owaVer"]))
            {
                this.renderDiagnosticInfo = true;
                stringBuilder.Append("X-OWA-Version: ");
                stringBuilder.Append(HttpContext.Current.Request.QueryString["owaVer"]);
                stringBuilder.Append("\n");
            }
            if (!string.IsNullOrWhiteSpace(Environment.MachineName))
            {
                this.renderDiagnosticInfo = true;
                stringBuilder.Append("X-FEServer: ");
                stringBuilder.Append(Environment.MachineName);
                stringBuilder.Append("\n");
            }
            if (!string.IsNullOrWhiteSpace(HttpContext.Current.Request.QueryString["be"]))
            {
                this.renderDiagnosticInfo = true;
                stringBuilder.Append("X-BEServer: ");
                stringBuilder.Append(HttpContext.Current.Request.QueryString["be"]);
                stringBuilder.Append("\n");
            }
            long fileTime;

            if (long.TryParse(HttpContext.Current.Request.QueryString["ts"], out fileTime))
            {
                this.renderDiagnosticInfo = true;
                stringBuilder.Append("Date: ");
                stringBuilder.Append(DateTime.FromFileTimeUtc(fileTime).ToString());
                stringBuilder.Append("\n");
            }
            else if (this.renderDiagnosticInfo)
            {
                stringBuilder.Append("Date: ");
                stringBuilder.Append(DateTime.UtcNow.ToString());
                stringBuilder.Append("\n");
            }
            this.diagnosticInfo = stringBuilder.ToString();
        }