protected void UserLogin(object sender, EventArgs e) { string username = txtUserName.Text.Trim(); string pwd = txtPwd.Text.Trim(); pwd = Utility.MD5(pwd.ToLower(), 32); string verifycode = txtVerify.Text.Trim(); if (Request.Cookies["VerifyCode"] == null) { //lblMsg.Text = "您的浏览器设置已被禁用 Cookies,您必须设置浏览器允许使用 Cookies 选项后才能使用本系统"; } //验证码是否证确 else if (String.Compare(Request.Cookies["VerifyCode"].Value, verifycode.ToUpper(), true) == 0) { Users bll = new Users(); ESMonitor.Model.Users model = new ESMonitor.Model.Users(); lbName.Text = string.Empty; lbPwd.Text = string.Empty; lbVerify.Text = string.Empty; if (bll.Exists(username)) { if (bll.CheckLogin(username, pwd)) { model = bll.GetModel(username); if (model.RoleId == 1) { bll.UpdateLastTime(model.UserId); SessionBox.CreateUserSession(new UserSession(model.UserId, model.UserName, model.RoleId, model.ReMark)); Response.Redirect("index.html"); } else { lbName.Text = "无权访问"; } } else { lbPwd.Text = "密码错误"; } } else { lbName.Text = "用户不存在"; } } else { lbVerify.Text = "验证码错误!"; } }
private void LoginVerify(string username, string pwd) { User userCrud = new User(); SF_User user = new SF_User(); if (userCrud.CheckLogin(username, pwd)) { user = userCrud.GetUserModel(username); var ds = userCrud.GetUserList2(string.Format("USERNAME='******'", username), "").Tables[0].Select(); if (ds[0]["USERSTATUS"].ToString() == "1") { //验证许可证 //LicHelper.LicHelper lic = new LicHelper.LicHelper(); //if (lic.CheckLicStatus()) //{ //string macid = lic.GetMachineCode(); //if (lic.IsMachine(macid)) //{ // if (lic.ContainDept(ds[0]["LEVELID"].ToString(), ds[0]["DEPTNAME"].ToString())) // { List <string> lst = new List <string>(); try { userCrud.UpdateLoginTime(Convert.ToDecimal(ds[0]["USERID"])); } catch { } SessionBox.CreateUserSession(new UserSession(Convert.ToDecimal(ds[0]["USERID"]), ds[0]["USERNAME"].ToString(), user.Role, null, ds[0]["LEVELID"].ToString(), user.UserGroupID, user.PersonNumber, ds[0]["NAME"].ToString(), ds[0]["DEPTNUMBER"].ToString(), ds[0]["DEPTNAME"].ToString(), user.UserStatus)); try { GhtnTech.SecurityFramework.BLL.LogManager.WriteLog(SessionBox.GetUserSession().PersonNumber, SessionBox.GetUserSession().LoginName, GetUserIP(), DateTime.Now, GhtnTech.SecurityFramework.BLL.ActiveType.登录, "", ""); } catch { } if (Request.Params["txtUrl"] != null) { Response.Redirect("~/MainFrame.aspx?txtUrl=" + Request.Params["txtUrl"].ToString().Trim()); } else { Response.Redirect("~/MainFrame.aspx"); } // } // else // { // JSHelper.AlertAndClose(UpdatePanel1, this, "您矿未获得授权。请联系管理员取得授权后再使用!"); // } //} //else //{ // JSHelper.AlertAndClose(UpdatePanel1, this, "您目前使用的服务器未获得授权。请联系管理员取得授权后再使用!"); //} //} //else //{ // if (ds[0]["LEVELID"].ToString().Contains('1') || ds[0]["LEVELID"].ToString().Contains('0')) // { // //Response.Redirect("UpdateLic.aspx", true); // //JSHelper.AlertAndRedirect(UpdatePanel1, "许可证已经过期!", "UpdateLic.aspx", this); // JSHelper.ShowModalDialogWindow(UpdatePanel1,this,"UpdateLic.aspx",800,500,100,200); // } // else // { // JSHelper.AlertAndClose(UpdatePanel1, this, "许可证已经过期!请联系管理员取得更新授权后再使用!"); // } //} // //Response.Redirect("~/Default.aspx"); } else { JSHelper.Alert(UpdatePanel1, this, "用户被锁定,请与管理员联系!"); } } else { JSHelper.Alert(UpdatePanel1, this, "用户名或密码错误!"); } }
protected void btn_login_Click(object sender, EventArgs e) { RedGlovePermission.BLL.Users bll = new RedGlovePermission.BLL.Users(); RedGlovePermission.Model.Users model = new RedGlovePermission.Model.Users(); if (UserName.Text.Trim() == "" || Password.Text.Trim() == "") { ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "", "alert('" + ResourceManager.GetString("Login_Msg_V_3") + "');", true); } else { if (bll.CheckLogin(UserName.Text.Trim(), RedGlovePermission.Lib.SecurityEncryption.MD5(Password.Text.Trim(), 32))) { model = bll.GetUserModel(UserName.Text.Trim()); if (model.RoleID != 0) { if (model.Status != 0) { #region 登录成功,将登录id存入hash表 Hashtable hOnline = (Hashtable)Application["Online"]; if (hOnline != null) { int i = 0; while (i < hOnline.Count) //增加此判断强制查询到底 { IDictionaryEnumerator idE = hOnline.GetEnumerator(); string strKey = ""; while (idE.MoveNext()) { if (idE.Value != null && idE.Value.ToString().Equals(model.UserName)) { //已经登录 strKey = idE.Key.ToString(); hOnline[strKey] = "XXXXXX"; break; } } i = i + 1; } } else { hOnline = new Hashtable(); } hOnline[Session.SessionID] = model.UserName; Application.Lock(); Application["Online"] = hOnline; Application.UnLock(); #endregion bll.UpdateLoginTime(model.UserID);//更新登录时间 Session["userLanguage"] = Language.SelectedValue; SessionBox.CreateUserSession(new UserSession(model.UserID, model.UserName, model.RoleID, model.IsLimit, model.Status)); Response.Redirect("~/Admin/Frameset/Default.aspx"); } else { ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "", "alert('" + ResourceManager.GetString("Login_Msg_2") + "');", true); } } else { ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "", "alert('" + ResourceManager.GetString("Login_Msg_3") + "');", true); } } else { ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "", "alert('" + ResourceManager.GetString("Login_Msg_2") + "');", true); } } }