예제 #1
0
        // Token: 0x06002542 RID: 9538 RVA: 0x0008669C File Offset: 0x0008489C
        internal static void LogUserContextData(HttpContext httpContext, RequestDetailsLogger logger)
        {
            if (OwaServerLogger.instance == null || !OwaServerLogger.instance.Configuration.IsLoggingEnabled)
            {
                return;
            }
            IMailboxContext mailboxContext = UserContextManager.GetMailboxContext(httpContext, null, false);

            if (mailboxContext != null && mailboxContext.ExchangePrincipal != null)
            {
                if (mailboxContext.IsExplicitLogon && mailboxContext.LogonIdentity != null)
                {
                    logger.Set(OwaServerLogger.LoggerData.User, mailboxContext.LogonIdentity.PrimarySmtpAddress);
                }
                logger.Set(OwaServerLogger.LoggerData.PrimarySmtpAddress, mailboxContext.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress);
                logger.Set(OwaServerLogger.LoggerData.MailboxGuid, mailboxContext.ExchangePrincipal.MailboxInfo.MailboxGuid);
                logger.Set(OwaServerLogger.LoggerData.RecipientType, mailboxContext.ExchangePrincipal.RecipientTypeDetails);
                Guid tenantGuid = mailboxContext.ExchangePrincipal.MailboxInfo.OrganizationId.GetTenantGuid();
                if (tenantGuid != Guid.Empty)
                {
                    logger.Set(OwaServerLogger.LoggerData.TenantGuid, tenantGuid);
                }
                string text = mailboxContext.Key.UserContextId.ToString(CultureInfo.InvariantCulture);
                logger.Set(OwaServerLogger.LoggerData.UserContext, text);
                if (!OwaServerLogger.TryAppendToIISLog(httpContext.Response, "&{0}={1}", new object[]
                {
                    UserContextCookie.UserContextCookiePrefix,
                    text
                }))
                {
                    ExTraceGlobals.RequestTracer.TraceWarning <Guid, string>((long)httpContext.GetHashCode(), "RequestId: {0}; Error appending UserContext '{1}' to IIS log.", logger.ActivityScope.ActivityId, text);
                }
                UserContext userContext = mailboxContext as UserContext;
                if (userContext != null && VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).OwaDeployment.LogTenantInfo.Enabled)
                {
                    if (!string.IsNullOrEmpty(userContext.LogEventCommonData.TenantDomain))
                    {
                        OwaServerLogger.TryAppendToIISLog(httpContext.Response, "&{0}={1}", new object[]
                        {
                            "domain",
                            userContext.LogEventCommonData.TenantDomain
                        });
                        logger.Set(OwaServerLogger.LoggerData.Tenant, userContext.LogEventCommonData.TenantDomain);
                    }
                    if (userContext.IsBposUser && !string.IsNullOrEmpty(userContext.BposSkuCapability))
                    {
                        OwaServerLogger.TryAppendToIISLog(httpContext.Response, "&{0}={1}", new object[]
                        {
                            "bpossku",
                            userContext.BposSkuCapability
                        });
                        logger.Set(OwaServerLogger.LoggerData.ServicePlan, userContext.BposSkuCapability);
                    }
                    if (!string.IsNullOrEmpty(userContext.LogEventCommonData.Flights))
                    {
                        logger.Set(OwaServerLogger.LoggerData.Flights, userContext.LogEventCommonData.Flights);
                    }
                    if (!string.IsNullOrEmpty(userContext.LogEventCommonData.Features))
                    {
                        logger.Set(OwaServerLogger.LoggerData.Features, userContext.LogEventCommonData.Features);
                    }
                    if (userContext.UserCulture != null && !string.IsNullOrEmpty(userContext.UserCulture.Name))
                    {
                        logger.Set(OwaServerLogger.LoggerData.UserContextCulture, userContext.UserCulture.Name);
                    }
                }
            }
            UserContextStatistics userContextStatistics = UserContextManager.GetUserContextStatistics(httpContext);

            if (userContextStatistics != null)
            {
                logger.Set(OwaServerLogger.LoggerData.UserContextLatency, userContextStatistics.AcquireLatency);
                logger.Set(OwaServerLogger.LoggerData.UserContextCreated, userContextStatistics.Created ? 1 : 0);
            }
        }