Ejemplo n.º 1
0
        private static string InternalGetLogOnName(bool autoRedirect, out ITicket ticket)
        {
            string userID = string.Empty;

            ticket = null;

            if (ImpersonateSettings.GetConfig().EnableTestUser)
            {
                //是否使用测试帐户
                userID = HttpContext.Current.Request.Headers["testUserID"];

                if (userID.IsNotEmpty())
                {
                    HttpContext.Current.Response.AppendHeader("testUserID", userID);
                }
                else
                {
                    userID = ImpersonateSettings.GetConfig().TestUserID;
                }
            }

            if (userID.IsNullOrEmpty())
            {
                userID = GetLogOnName(autoRedirect, out ticket);
            }

            return(userID);
        }
Ejemplo n.º 2
0
        private static IPrincipal DoAuthentication(bool autoRedirect)
        {
            IPrincipal principal = null;
            ITicket    ticket;

            string logonName = InternalGetLogOnName(autoRedirect, out ticket);

            if (logonName.IsNotEmpty())
            {
                logonName = ImpersonateSettings.GetConfig().Impersonation[logonName];

                LogOnIdentity loi = new LogOnIdentity(logonName);

                if (ticket != null)
                {
                    ticket.SignInInfo.UserID = loi.LogOnNameWithDomain;
                }

                principal = SetPrincipal(loi.LogOnNameWithDomain, ticket);
            }

            return(principal);
        }