Esempio n. 1
0
        internal static UserContextKey CreateNew(SecurityIdentifier sid)
        {
            string text  = null;
            string text2 = sid.ToString();

            return(UserContextKey.Create(UserContextUtilities.GetNewGuid(), text2, text));
        }
Esempio n. 2
0
        private static UserContextKey GetUserContextKey(HttpContext httpContext, ClientSecurityContext overrideClientSecurityContext, out UserContextCookie userContextCookie)
        {
            UserContextKey userContextKey    = null;
            string         explicitLogonUser = UserContextUtilities.GetExplicitLogonUser(httpContext);

            if (string.IsNullOrEmpty(explicitLogonUser))
            {
                userContextCookie = UserContextCookie.GetUserContextCookie(httpContext);
                if (userContextCookie != null)
                {
                    ExTraceGlobals.UserContextCallTracer.TraceDebug <UserContextCookie>(0L, "Found cookie in the request: {0}", userContextCookie);
                    if (overrideClientSecurityContext == null)
                    {
                        userContextKey = UserContextKey.CreateFromCookie(userContextCookie, httpContext);
                    }
                    else
                    {
                        userContextKey = UserContextKey.CreateFromCookie(userContextCookie, overrideClientSecurityContext.UserSid);
                    }
                }
            }
            else
            {
                userContextCookie = null;
                if (UserContextManager.RequestRequiresSharedContext(httpContext))
                {
                    userContextKey = UserContextKey.Create("D894745CADD64DB9B00309200288E1E7", "SharedAdmin", explicitLogonUser);
                }
                else
                {
                    SecurityIdentifier securityIdentifier = httpContext.User.Identity.GetSecurityIdentifier();
                    if (securityIdentifier == null)
                    {
                        ExTraceGlobals.UserContextCallTracer.TraceDebug <IIdentity>(0L, "UserContextManager.GetUserContextKey: current user has no security identifier - '{0}'", httpContext.User.Identity);
                        ExWatson.SendReport(new InvalidOperationException(string.Format("UserContextManager.GetUserContextKey: current user has no security identifier - '{0}'", httpContext.User.Identity)), ReportOptions.None, null);
                        return(null);
                    }
                    string logonUniqueKey = securityIdentifier.ToString();
                    string text           = httpContext.Request.Headers["X-OWA-Test-ExplicitLogonUserId"];
                    if (string.IsNullOrEmpty(text) || !AppConfigLoader.GetConfigBoolValue("Test_OwaAllowHeaderOverride", false))
                    {
                        text = "B387FD19C8C4416694EB79909BED70B5";
                    }
                    userContextKey = UserContextKey.Create(text, logonUniqueKey, explicitLogonUser);
                    ExTraceGlobals.UserContextCallTracer.TraceDebug <UserContextKey>(0L, "Cookie not found but this is explicit logon. Generated Key: {0}", userContextKey);
                }
            }
            return(userContextKey);
        }
Esempio n. 3
0
        internal static UserContextKey CreateNew(OwaIdentity logonIdentity, OwaIdentity mailboxIdentity, HttpContext httpContext)
        {
            if (logonIdentity == null)
            {
                throw new ArgumentNullException("logonIdentity");
            }
            string        uniqueId      = logonIdentity.UniqueId;
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendFormat("userContextLogonIdentityName=<PII>{0}</PII>", logonIdentity.SafeGetRenderableName());
            if (logonIdentity.UserSid != null)
            {
                stringBuilder.AppendFormat("userContextLogonIdentitySid=<PII>{0}</PII>", logonIdentity.UserSid.ToString());
            }
            string text = null;

            if (mailboxIdentity != null)
            {
                text = mailboxIdentity.UniqueId;
                stringBuilder.AppendFormat("userContextMbIdentityName=<PII>{0}</PII>", mailboxIdentity.SafeGetRenderableName());
                if (mailboxIdentity.UserSid != null)
                {
                    stringBuilder.AppendFormat("userContextMbIdentitySid=<PII>{0}</PII>", mailboxIdentity.UserSid.ToString());
                }
            }
            try
            {
                string text2 = stringBuilder.ToString();
                if (LiveIdAuthenticationModule.IdentityTracingEnabled && !string.IsNullOrWhiteSpace(text2))
                {
                    httpContext.Response.AppendToLog(text2);
                }
            }
            catch (Exception)
            {
            }
            return(UserContextKey.Create(UserContextUtilities.GetNewGuid(), uniqueId, text));
        }