示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void cmdOK_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text.Trim() == "" || txtPassword.Text.Trim() == "")
            {
                Response.Write(@"<script language='javascript'>alert('用户名和密码不能为空!'); </script> ");
                return;
            }
            try
            {
                //验证用户登录
                string loginID  = txtUserName.Text;
                string Password = txtPassword.Text;

                //解密
                //loginID = AESDecrypt(loginID, "AjQ0YQ0MvKKC1uTr", "AjQ0YQ0MvKKC1uTr");
                //Password = AESDecrypt(Password, "AjQ0YQ0MvKKC1uTr", "AjQ0YQ0MvKKC1uTr");
                SeatManage.Bll.Users_ALL userinfocheck = new SeatManage.Bll.Users_ALL();
                loginID = userinfocheck.CheckUser(loginID, Password);
                //判断返回信息是否为空
                if (string.IsNullOrEmpty(loginID))
                {
                    Response.Write(@"<script language='javascript'>alert('用户或密码错误,请重新输入'); </script> ");
                }
                else
                {
                    this.LoginId = loginID;
                    Response.Redirect("Florms/FormSYS.aspx");
                }
            }
            catch (Exception ex)
            {
                SeatManage.SeatManageComm.WriteLog.Write(ex.ToString());
                Response.Write(@"<script language='javascript'>alert('数据库连接出错!'); </script> ");
            }
        }
        //unlockScreen
        public JsonResult UnlockScreen(string password)
        {
            JsonResult result = null;

            try
            {
                if (!IsLogin())
                {
                    Response.Write("<html><head><title>系统安全提示</title><script>alert('当前登录账户已经超时,请重新登录');location.href='" + Url.Action("Index", "Login") + "'</script></head><body></body></html>");
                    Response.End();
                }

                SeatManage.Bll.Users_ALL userinfocheck = new SeatManage.Bll.Users_ALL();
                string loginID = userinfocheck.CheckUser(LoginId, password);

                if (string.IsNullOrEmpty(loginID))
                {
                    result = Json(new { status = "no", message = "密码错误,请重新输入" }, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    result = Json(new { status = "yes", message = "登录成功" }, JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception ex)
            {
                result = Json(new { status = "no", message = ex.ToString() }, JsonRequestBehavior.AllowGet);
            }

            return(result);
        }
        public JsonResult CheckLogin(string username,string password)
        {
            JsonResult result = null;
            string loginID = username;
            string Password = password;

            try
            {
                SeatManage.Bll.Users_ALL userinfocheck = new SeatManage.Bll.Users_ALL();
                loginID = userinfocheck.CheckUser(loginID, Password);

                if (string.IsNullOrEmpty(loginID))
                {
                    result = Json(new { status = "no", message = "用户或密码错误,请重新输入" }, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    Session["LoginID"] = loginID;
                    result = Json(new { status = "yes", message = "登录成功" }, JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception ex)
            {
                result = Json(new { status = "no", message = ex.ToString() }, JsonRequestBehavior.AllowGet);
            }

            return result;
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string cmd = Request.Form["subCmd"];

            if (Request.Cookies["userInfo"] != null)//存在记录的cookies信息
            {
                string loginId = CookiesManager.GetCookiesValue(CookiesManager.LoginID);
                SeatManage.ClassModel.UserInfo LoginUser = GetUserInfo(loginId);
                Session[CookiesManager.LoginID] = LoginUser.LoginId;
                Session[CookiesManager.Name]    = LoginUser.UserName;
                Response.Redirect("Pad/SeatPad.aspx");
            }
            //通过页面验证,执行登录操作
            if (cmd == "Login")
            {
                string loginId  = txt_LoginID.Value;
                string password = txt_Password.Value;
                SeatManage.Bll.Users_ALL userinfocheck = new SeatManage.Bll.Users_ALL();
                try
                {
                    loginId = userinfocheck.CheckUser(loginId, password);
                    //判断返回信息是否为空
                    if (string.IsNullOrEmpty(loginId))
                    {
                        spanWarmInfo.Visible   = true;
                        spanWarmInfo.InnerText = "用户名或密码错误";
                    }
                    else
                    {
                        SeatManage.ClassModel.UserInfo LoginUser = GetUserInfo(loginId);
                        Session[CookiesManager.LoginID] = LoginUser.LoginId;
                        Session[CookiesManager.Name]    = LoginUser.UserName;
                        if (LoginUser.UserType == SeatManage.EnumType.UserType.Admin)
                        {
                            //若选择记住密码,则记录用户信息cookies
                            if (chk_RemPasspword.Checked == true)
                            {
                                CookiesManager.SetPadCookies(loginId, password);
                            }
                            else//清除cookies
                            {
                                CookiesManager.RemoveCookies("userInfo");
                            }
                            Response.Redirect("Pad/SeatPad.aspx");
                        }
                        else
                        {
                            spanWarmInfo.Visible   = true;
                            spanWarmInfo.InnerText = "您不具备访问权限";
                        }
                    }
                }
                catch (Exception ex)
                {
                    spanWarmInfo.Visible   = true;
                    spanWarmInfo.InnerText = "数据库连接出错";
                }
            }
        }
 public bool Check(string userName, string password)
 {
     if (string.IsNullOrEmpty(password) || string.IsNullOrEmpty(userName))
     {
         ErrorMessage = "用户名或密码不能为空!";
         return(false);
     }
     if (userName != "admin" && userName != "juneberry")
     {
         ErrorMessage = "用户名或密码错误!";
         return(false);
     }
     try
     {
         if (userName == "admin")
         {
             SeatManage.Bll.Users_ALL checkBll = new SeatManage.Bll.Users_ALL();
             if (checkBll.CheckUser(userName, password) != "admin")
             {
                 ErrorMessage = "用户名或密码错误!";
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             string   schoolNo = SeatManage.Bll.Registry.GetSchoolNum();
             DateTime dt       = DateTime.Now;
             string   cps      = SeatManage.SeatManageComm.MD5Algorithm.GetMD5Str32(schoolNo);
             string   dts      = SeatManage.SeatManageComm.MD5Algorithm.GetMD5Str32((dt.Year + dt.Month + dt.Day + dt.Hour).ToString());
             string   pw       = SeatManage.SeatManageComm.MD5Algorithm.GetMD5Str32("Juneberry" + cps + dts);
             if (password == pw && userName == "juneberry")
             {
                 _IsJuneberry = true;
                 return(true);
             }
             else
             {
                 ErrorMessage = "用户名或密码错误!";
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         ErrorMessage = ex.Message;
         return(false);
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void cmdOK_Click(object sender, ImageClickEventArgs e)
 {
     if (txtUserName.Text.Trim() == "" || txtPassword.Text.Trim() == "")
     {
         Response.Write(@"<script language='javascript'>alert('用户名和密码不能为空!'); </script> ");
         return;
     }
     try
     {
         //验证用户登录
         string loginID  = txtUserName.Text;
         string Password = txtPassword.Text;
         SeatManage.Bll.Users_ALL userinfocheck = new SeatManage.Bll.Users_ALL();
         loginID = userinfocheck.CheckUser(loginID, Password);
         //判断返回信息是否为空
         if (string.IsNullOrEmpty(loginID))
         {
             Response.Write(@"<script language='javascript'>alert('用户或密码错误,请重新输入'); </script> ");
         }
         else
         {
             SeatManage.ClassModel.UserInfo user = SeatManage.Bll.Users_ALL.GetUserInfo(loginID);
             if (user != null)
             {
                 string userIP = GetLoginIp();
                 if (!string.IsNullOrEmpty(userIP) && !string.IsNullOrEmpty(user.LockIPAdress) && user.LockIPAdress != "0.0.0.0" && user.LockIPAdress != userIP)
                 {
                     Response.Write(@"<script language='javascript'>alert('对不起您登录的IP地址没有经过授权!'); </script> ");
                 }
                 else
                 {
                     this.LoginId = loginID;
                     Response.Redirect("Florms/FormSYS.aspx");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Response.Write(@"<script language='javascript'>alert('数据库连接出错!'); </script> ");
     }
 }
        // GET: xmulogin
        public ActionResult Index(string ticket = "")
        {
            if (!string.IsNullOrEmpty(ticket))//拿到票据 去校验ticket
            {
                var CasCallbackUrl = GetAppSetting("CasCallbackUrl");

                string url = "http://ids.xmu.edu.cn/authserver/serviceValidate?ticket=" + ticket + "&service=" + CasCallbackUrl;
                var    xml = GetXML(url);

                if (!string.IsNullOrEmpty(xml))//拿到用户xml
                {
                    SeatManage.Bll.Users_ALL userinfocheck = new SeatManage.Bll.Users_ALL();
                    var index1   = xml.IndexOf("<cas:user>");
                    var index2   = xml.IndexOf("</cas:user>");
                    var loginID  = xml.Substring(index1 + 10, index2 - index1 - 10);
                    var userInfo = SeatManage.Bll.Users_ALL.GetUserInfo(loginID);
                    if (userInfo != null)
                    {
                        //登录
                        Session["LoginID"]  = loginID;
                        Session["casLogin"] = "******";
                        return(RedirectToAction("index", "home"));
                    }
                    else
                    {
                        TempData["msg"] = "用户未注册!";
                        return(RedirectToAction("index", "login"));
                    }
                }
                else
                {
                    TempData["msg"] = "登录失败!";
                    return(RedirectToAction("index", "login"));
                }
            }

            return(RedirectToAction("index", "login"));
        }
示例#8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string userName = User.Identity.Name;
            //SeatManage.SeatManageComm.WriteLog.Write(userName);
            //登录成功重定向url参数
            string redirectUrl = Request.QueryString["redirectUrl"];

            //string tickets = Request.QueryString["CASTGC"];
            if (string.IsNullOrEmpty(userName))
            {
                DotNetCasClient.CasAuthentication.RedirectToLoginPage();
                return;
            }

            string cardNo = userName;

            SeatManage.Bll.Users_ALL userinfocheck = new SeatManage.Bll.Users_ALL();
            string loginID = userinfocheck.CheckUser(cardNo, cardNo);

            if (string.IsNullOrEmpty(loginID))
            {
                // Response.Write("对不起,您所请求的座位管理系统没有授权,请与管理员联系。 ");
                return;
            }
            else
            {
                this.LoginId = loginID;
            }
            if (string.IsNullOrEmpty(redirectUrl))
            {
                redirectUrl = defaultTargetUrl;
            }
            Response.Redirect(redirectUrl);


            ////string userName = User.Identity.Name;

            /////获取用户其他的属性,案例,部分代码,获取方式优化中
            //HttpCookie ticketCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
            //FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(ticketCookie.Value);
            //CasAuthenticationTicket casTicket = CasAuthentication.ServiceTicketManager.GetTicket(ticket.UserData);
            //Dictionary<string, string> userAttrs = new Dictionary<string, string>();
            //foreach (KeyValuePair<string, IList<string>> attribute in casTicket.Assertion.Attributes)
            //{
            //    string key = attribute.Key;
            //    Response.Write("key:" + key + "::::" + attribute.Value);
            //    StringBuilder builder = new StringBuilder();
            //    foreach (string valuePart in attribute.Value)
            //    { builder.AppendLine("        " + valuePart); }
            //    userAttrs.Add(key, builder.ToString());
            //}
            //foreach (var VARIABLE in userAttrs)
            //{
            //    SeatManage.SeatManageComm.WriteLog.Write(VARIABLE.Key + "'" + VARIABLE.Value);

            //}



            ////备注
            //SeatManage.SeatManageComm.WriteLog.Write(redirectUrl ?? "");

            //if (string.IsNullOrEmpty(redirectUrl))
            //{
            //    redirectUrl = defaultTargetUrl;//默认首页
            //}
            ////备注
            //SeatManage.SeatManageComm.WriteLog.Write(Session["uid"] == null ? "" : Session["uid"].ToString());

            ////已经登录直接跳回
            //if (Session["uid"] != null && !string.IsNullOrEmpty(this.LoginId))
            //{
            //    Response.Redirect(redirectUrl);
            //    return;
            //}
            //loginaspx += "?redirectUrl=" + redirectUrl;
            //loginaspx = HttpUtility.UrlEncode(loginaspx);



            //string ticket = Request.QueryString["ticket"];
            //if (string.IsNullOrEmpty(ticket))
            //{
            //    Response.Redirect(loginServer + "?service=" + loginaspx);
            //    return;
            //}



            ////string validateUrl = validateServer + "?ticket=" + ticket + "&service=" + loginaspx
            //string validateUrl = validateServer + "?ticket=" + ticket;

            //SeatManage.SeatManageComm.WriteLog.Write(validateUrl);


            //System.Net.ServicePointManager.CertificatePolicy = new MyPolicy();

            //StreamReader Reader = new StreamReader(new WebClient().OpenRead(validateUrl));
            //string resp = Reader.ReadToEnd();

            //SeatManage.SeatManageComm.WriteLog.Write(resp);

            //NameTable nt = new NameTable();
            //XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
            //XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
            //XmlTextReader reader = new XmlTextReader(resp, XmlNodeType.Element, context);

            //string uid = null;
            //string userName = null;
            //bool authSuccess = false;

            //while (reader.Read())
            //{
            //    if (reader.IsStartElement())
            //    {
            //        string tag = reader.LocalName;
            //        if (tag == "authenticationSuccess")
            //            authSuccess = true;
            //        if (tag == "user")
            //            uid = reader.ReadString();
            //        if (tag == "cn")
            //            userName = reader.ReadString();
            //    }
            //}
            //reader.Close();


            ////备注
            //SeatManage.SeatManageComm.WriteLog.Write(uid ?? "");
            ////备注
            //SeatManage.SeatManageComm.WriteLog.Write(userName ?? "");
            ////备注
            //SeatManage.SeatManageComm.WriteLog.Write(authSuccess.ToString());


            //if (!authSuccess || uid == null)
            //{
            //    Response.Redirect(loginServer + "?service=" + loginaspx);
            //    return;
            //}
            //else
            //{
        }