Exemple #1
0
    public SysUserInfo GetCurrentUserInfo()
    {
        SysUserInfo user;

        try
        {
            user = this.Session["user"] as SysUserInfo;
        }
        catch
        {
            user = null;
        }

        if (user != null)
        {
            return(user);
        }

        string domain_account = HttpContext.Current.User.Identity.Name;

        if (!string.IsNullOrEmpty(domain_account)) // 用户已通过NT认证
        {
            user = UserBiz.GetUserByAccount(domain_account);
            if (user != null) // 登录成功
            {
                //user.LastLogonTime = DateTime.Now;
                // UserBiz._UpdateUser(user);
                UserBiz.DoLogin(user);

                Session["user"] = user;
            }
            else
            {
                throw new Exception("there is no information of " + domain_account + " in database");
            }
        }
        else // 用户未通过NT认证
        {
            throw new Exception("Access Denied");
        }
        return(user);
    }