示例#1
0
        // Token: 0x0600025B RID: 603 RVA: 0x0000FDDC File Offset: 0x0000DFDC
        private void Application_BeginRequest(object sender, EventArgs e)
        {
            RequestDetailsLoggerBase <RequestDetailsLogger> .InitializeRequestLogger();

            RequestDetailsLoggerBase <RequestDetailsLogger> .Current.ActivityScope.UpdateFromMessage(HttpContext.Current.Request);

            RequestDetailsLoggerBase <RequestDetailsLogger> .Current.ActivityScope.SerializeTo(HttpContext.Current.Response);

            string sourceCafeServer = CafeHelper.GetSourceCafeServer(HttpContext.Current.Request);

            if (!string.IsNullOrEmpty(sourceCafeServer))
            {
                RequestDetailsLoggerBase <RequestDetailsLogger> .Current.Set(AutoDiscoverMetadata.FrontEndServer, sourceCafeServer);
            }
            Microsoft.Exchange.Diagnostics.Components.Autodiscover.ExTraceGlobals.FrameworkTracer.TraceDebug <string, string>((long)this.GetHashCode(), "[Application_BeginRequest()] Request.Path=\"{0}\"; Request.PhysicalPath=\"{1}\";", base.Request.Path, base.Request.PhysicalPath);
            int    num      = base.Request.Path.IndexOf('\\');
            string fullPath = Path.GetFullPath(base.Request.PhysicalPath);

            if (num >= 0 || fullPath != base.Request.PhysicalPath)
            {
                Microsoft.Exchange.Diagnostics.Components.Autodiscover.ExTraceGlobals.FrameworkTracer.TraceError <int, string>((long)this.GetHashCode(), "[Application_BeginRequest()] IndexOf('\\')={0};FullPath=\"{1}\"; // Throwing 404 HttpException", num, fullPath);
                this.exception = new HttpException(404, string.Empty);
                throw this.exception;
            }
        }
示例#2
0
        protected override ICollection <KeyValuePair <string, object> > GetComponentSpecificData(IActivityScope activityScope, string eventId)
        {
            Dictionary <string, object> dictionary = null;

            if (activityScope != null)
            {
                HttpContext httpContext = HttpContext.Current;
                if (httpContext != null)
                {
                    string sourceCafeServer = CafeHelper.GetSourceCafeServer(httpContext.Request);
                    if (!string.IsNullOrEmpty(sourceCafeServer))
                    {
                        activityScope.SetProperty(ActivityContextLoggerMetaData.FrontEndServer, sourceCafeServer);
                    }
                    string requestUrlForLog = httpContext.GetRequestUrlForLog();
                    activityScope.SetProperty(ActivityContextLoggerMetaData.Url, requestUrlForLog);
                }
                RbacPrincipal current = RbacPrincipal.GetCurrent(false);
                if (current != null)
                {
                    string value;
                    if (current.RbacConfiguration.DelegatedPrincipal != null)
                    {
                        value = current.RbacConfiguration.DelegatedPrincipal.UserId;
                    }
                    else
                    {
                        SmtpAddress executingUserPrimarySmtpAddress = current.RbacConfiguration.ExecutingUserPrimarySmtpAddress;
                        value = (executingUserPrimarySmtpAddress.IsValidAddress ? executingUserPrimarySmtpAddress.ToString() : current.RbacConfiguration.ExecutingUserPrincipalName);
                    }
                    if (!string.IsNullOrEmpty(value))
                    {
                        activityScope.SetProperty(ActivityContextLoggerMetaData.PrimarySmtpAddress, value);
                    }
                    OrganizationId organizationId = current.RbacConfiguration.OrganizationId;
                    if (organizationId != null && organizationId.OrganizationalUnit != null)
                    {
                        string name = organizationId.OrganizationalUnit.Name;
                        activityScope.SetProperty(ActivityContextLoggerMetaData.Organization, name);
                    }
                }
                dictionary = new Dictionary <string, object>(ActivityContextLogger.EnumToShortKeyMapping.Count);
                ExtensibleLogger.CopyPIIProperty(activityScope, dictionary, ActivityContextLoggerMetaData.PrimarySmtpAddress, ActivityContextLogger.PrimarySmtpAddressKey);
                ExtensibleLogger.CopyProperties(activityScope, dictionary, ActivityContextLogger.EnumToShortKeyMapping);
            }
            return(dictionary);
        }
示例#3
0
        private void InternalCreateAsyncRequest(HttpContext httpContext, string orgIdPuid, string upn, string rpsHeaders)
        {
            HttpRequest request = httpContext.Request;

            if (request.HttpMethod != HttpMethod.Post.ToString() || !request.RawUrl.Contains("wsignin") || request.Cookies["RPSAuth"] != null)
            {
                ExTraceGlobals.CoreTracer.TraceWarning(0L, string.Format("[PreloadSessionDataRequestCreator::InternalCreateAsyncRequest]: Not the logon postback request. Hence returning... Method = {0}, RawUrl = {1}, RpsAuth cookie present = {2}", request.HttpMethod, request.RawUrl, request.Cookies["RPSAuth"] != null));
                return;
            }
            string sourceCafeServer = CafeHelper.GetSourceCafeServer(request);

            if (string.IsNullOrWhiteSpace(sourceCafeServer))
            {
                ExTraceGlobals.CoreTracer.TraceError(0L, "[PreloadSessionDataRequestCreator::InternalCreateAsyncRequest]: cannot send preload request becuase the CAFE server that made the request cannot be determined");
                return;
            }
            HttpWebRequest preloadRequest = (HttpWebRequest)WebRequest.Create(new UriBuilder(request.GetRequestUrlEvenIfProxied().ToString().Split(new char[]
            {
                '?'
            })[0] + "PreloadSessionData.ashx")
            {
                Host = sourceCafeServer
            }.Uri);

            preloadRequest.Method            = request.HttpMethod;
            preloadRequest.Timeout           = 20000;
            preloadRequest.PreAuthenticate   = true;
            preloadRequest.UserAgent         = request.UserAgent;
            preloadRequest.KeepAlive         = false;
            preloadRequest.ContentLength     = 0L;
            preloadRequest.AllowAutoRedirect = false;
            this.SetCookies(httpContext, preloadRequest, upn, rpsHeaders);
            preloadRequest.ServerCertificateValidationCallback = this.remoteCertificateValidationCallback;
            PreloadSessionDataRequestCreator.preloadThrottlingCache.TryInsertAbsolute(orgIdPuid, true, new TimeSpan(0, 0, 5));
            ThreadPool.QueueUserWorkItem(delegate(object stateInfo)
            {
                this.ExecuteAsyncRequest(preloadRequest);
            });
        }
        // Token: 0x060000D4 RID: 212 RVA: 0x00005FE8 File Offset: 0x000041E8
        private void OnBeginRequest(object sender, EventArgs e)
        {
            ExTraceGlobals.HttpModuleTracer.TraceFunction((long)this.GetHashCode(), "[LoggingStartModule::OnBeginRequest] Enter");
            LatencyTracker latencyTracker = new LatencyTracker(Constants.IsPowerShellWebService ? "Psws.HttpModule" : "Rps.HttpModule", null);

            latencyTracker.Start();
            HttpContext         httpContext = HttpContext.Current;
            HttpRequest         request     = httpContext.Request;
            NameValueCollection headers     = httpContext.Request.Headers;

            httpContext.Items["Logging-HttpRequest-Latency"] = latencyTracker;
            HttpLogger.InitializeRequestLogger();
            if (HttpLogger.ActivityScope != null)
            {
                HttpLogger.ActivityScope.UpdateFromMessage(HttpContext.Current.Request);
                HttpLogger.ActivityScope.SerializeTo(HttpContext.Current.Response);
            }
            if (Constants.IsRemotePS && HttpLogger.ActivityScope != null && request.Url.Port == 444)
            {
                Uri url = request.Url;
                NameValueCollection urlProperties = url.GetUrlProperties();
                string text = urlProperties["RequestId48CD6591-0506-4D6E-9131-797489A3260F"];
                Guid   guid;
                if (text != null && Guid.TryParse(text, out guid))
                {
                    LoggerHelper.UpdateActivityScopeRequestIdFromUrl(url.ToString());
                }
            }
            HttpLogger.SafeSetLogger(ServiceCommonMetadata.HttpMethod, request.HttpMethod);
            WinRMInfo winRMInfoFromHttpHeaders = WinRMInfo.GetWinRMInfoFromHttpHeaders(headers);

            if (winRMInfoFromHttpHeaders != null)
            {
                HttpLogger.SafeSetLogger(RpsHttpMetadata.Action, winRMInfoFromHttpHeaders.Action);
                HttpLogger.SafeSetLogger(RpsCommonMetadata.SessionId, winRMInfoFromHttpHeaders.SessionId);
                HttpLogger.SafeSetLogger(RpsHttpMetadata.ShellId, winRMInfoFromHttpHeaders.ShellId);
                HttpLogger.SafeSetLogger(RpsHttpMetadata.CommandId, winRMInfoFromHttpHeaders.CommandId);
                HttpLogger.SafeSetLogger(RpsHttpMetadata.CommandName, winRMInfoFromHttpHeaders.CommandName);
                httpContext.Items["X-RemotePS-WinRMInfo"] = winRMInfoFromHttpHeaders;
            }
            string sourceCafeServer = CafeHelper.GetSourceCafeServer(request);

            if (sourceCafeServer != null)
            {
                HttpLogger.SafeSetLogger(ConfigurationCoreMetadata.FrontEndServer, sourceCafeServer);
            }
            Uri url2 = request.Url;

            if (url2.IsAbsoluteUri)
            {
                HttpLogger.SafeSetLogger(ConfigurationCoreMetadata.UrlHost, url2.DnsSafeHost);
                HttpLogger.SafeSetLogger(ConfigurationCoreMetadata.UrlStem, url2.LocalPath);
                HttpLogger.SafeSetLogger(ConfigurationCoreMetadata.UrlQuery, url2.Query);
            }
            else
            {
                HttpLogger.SafeAppendGenericError("InvalidRelativeUri", url2.ToString(), false);
            }
            NameValueCollection urlProperties2 = url2.GetUrlProperties();

            if (urlProperties2 != null)
            {
                string text2;
                if (!string.IsNullOrWhiteSpace(text2 = urlProperties2["Organization"]))
                {
                    HttpLogger.SafeSetLogger(ConfigurationCoreMetadata.ManagedOrganization, text2);
                }
                else if (!string.IsNullOrWhiteSpace(text2 = urlProperties2["DelegatedOrg"]))
                {
                    HttpLogger.SafeSetLogger(ConfigurationCoreMetadata.ManagedOrganization, "Delegate:" + text2);
                }
            }
            if (HttpLogger.ActivityScope != null)
            {
                using (new MonitoredScope("RequestMonitor.Register", "RequestMonitor.Register", HttpModuleHelper.HttpPerfMonitors))
                {
                    RequestMonitor.Instance.RegisterRequest(HttpLogger.ActivityScope.ActivityId);
                    string text3 = headers[WellKnownHeader.WLIDMemberName] ?? headers[WellKnownHeader.LiveIdMemberName];
                    if (!string.IsNullOrEmpty(text3))
                    {
                        SmtpAddress smtpAddress = new SmtpAddress(text3);
                        RequestMonitor.Instance.Log(HttpLogger.ActivityScope.ActivityId, RequestMonitorMetadata.AuthenticatedUser, text3);
                        RequestMonitor.Instance.Log(HttpLogger.ActivityScope.ActivityId, RequestMonitorMetadata.Organization, smtpAddress.Domain);
                    }
                    RequestMonitor.Instance.Log(HttpLogger.ActivityScope.ActivityId, RequestMonitorMetadata.FrontEndServer, sourceCafeServer);
                    RequestMonitor.Instance.Log(HttpLogger.ActivityScope.ActivityId, RequestMonitorMetadata.ProtocolAction, HttpLogger.ActivityScope.GetProperty(RpsHttpMetadata.Action));
                }
            }
            ExTraceGlobals.HttpModuleTracer.TraceFunction((long)this.GetHashCode(), "[LoggingStartModule::OnBeginRequest] Exit");
        }
示例#5
0
        // Token: 0x06002543 RID: 9539 RVA: 0x000869C8 File Offset: 0x00084BC8
        internal static void LogHttpContextData(HttpContext httpContext, RequestDetailsLogger logger)
        {
            if (OwaServerLogger.instance == null || !OwaServerLogger.instance.Configuration.IsLoggingEnabled)
            {
                return;
            }
            if (logger.Get(ExtensibleLoggerMetadata.EventId) == null)
            {
                if (!logger.ActivityScope.Statistics.Any <KeyValuePair <OperationKey, OperationStatistics> >())
                {
                    return;
                }
                OwaServerLogger.SetEventId(httpContext, logger);
            }
            logger.Set(OwaServerLogger.LoggerData.ContentLength, httpContext.Request.ContentLength);
            logger.Set(ServiceLatencyMetadata.HttpPipelineLatency, httpContext.Items[ServiceLatencyMetadata.HttpPipelineLatency]);
            NameValueCollection headers = httpContext.Request.Headers;
            string value = headers["X-OWA-ActionId"];

            if (!string.IsNullOrEmpty(value))
            {
                logger.Set(OwaServerLogger.LoggerData.ClientActionId, value);
            }
            string value2 = headers["X-OWA-ActionName"];

            if (!string.IsNullOrEmpty(value2))
            {
                logger.Set(OwaServerLogger.LoggerData.ClientActionName, value2);
            }
            string value3 = headers["X-EXT-ClientName"];

            if (!string.IsNullOrEmpty(value3))
            {
                logger.Set(OwaServerLogger.LoggerData.ExternalClientName, value3);
            }
            string value4 = headers["X-EXT-CorrelationId"];

            if (!string.IsNullOrEmpty(value4))
            {
                logger.Set(OwaServerLogger.LoggerData.ExternalCorrelationId, value4);
            }
            string sourceCafeServer = CafeHelper.GetSourceCafeServer(httpContext.Request);

            if (!string.IsNullOrEmpty(sourceCafeServer))
            {
                logger.Set(OwaServerLogger.LoggerData.FrontEndServer, sourceCafeServer);
            }
            string value5 = headers["X-OWA-OfflineRejectCode"];

            if (!string.IsNullOrEmpty(value5))
            {
                logger.Set(OwaServerLogger.LoggerData.OfflineRejectCode, value5);
            }
            string text = headers["logonLatency"];
            bool   flag = UserContextUtilities.IsDifferentMailbox(httpContext);

            if (!string.IsNullOrEmpty(text) || flag)
            {
                IMailboxContext mailboxContext = UserContextManager.GetMailboxContext(httpContext, null, false);
                if (!string.IsNullOrEmpty(text))
                {
                    logger.Set(OwaServerLogger.LoggerData.LogonLatencyName, text);
                    string userContext = string.Empty;
                    if (mailboxContext != null)
                    {
                        userContext = mailboxContext.Key.UserContextId.ToString(CultureInfo.InvariantCulture);
                    }
                    string[] keys = new string[]
                    {
                        "LGN.L"
                    };
                    string[] values = new string[]
                    {
                        text
                    };
                    Datapoint      datapoint = new Datapoint(DatapointConsumer.Analytics, "LogonLatency", DateTime.UtcNow.ToString("o"), keys, values);
                    ClientLogEvent logEvent  = new ClientLogEvent(datapoint, userContext);
                    OwaClientLogger.AppendToLog(logEvent);
                }
                if (flag && mailboxContext is SharedContext && httpContext.Items.Contains("CallContext"))
                {
                    CallContext callContext = httpContext.Items["CallContext"] as CallContext;
                    logger.Set(OwaServerLogger.LoggerData.User, callContext.GetEffectiveAccessingSmtpAddress());
                }
            }
            string value6 = httpContext.Items["BackEndAuthenticator"] as string;

            if (!string.IsNullOrEmpty(value6))
            {
                logger.Set(OwaServerLogger.LoggerData.BackendAuthenticator, value6);
            }
            object obj = httpContext.Items["TotalBERehydrationModuleLatency"];

            if (obj != null)
            {
                logger.Set(OwaServerLogger.LoggerData.RehydrationModuleLatency, obj);
            }
            string value7 = headers["X-OWA-Test-PassThruProxy"];

            if (!string.IsNullOrEmpty(value7))
            {
                logger.Set(OwaServerLogger.LoggerData.PassThroughProxy, value7);
            }
            string value8 = headers["X-SuiteServiceProxyOrigin"];

            if (!string.IsNullOrEmpty(value8))
            {
                logger.Set(OwaServerLogger.LoggerData.SuiteServiceProxyOrigin, value8);
            }
            HttpCookie httpCookie = httpContext.Request.Cookies["ClientId"];

            if (httpCookie != null)
            {
                logger.Set(OwaServerLogger.LoggerData.ClientId, httpCookie.Value);
            }
        }