public void RaiseCallbackEvent(string eventArgument) { //匿名用户登录 if (String.IsNullOrEmpty(eventArgument)) { FormsAuthentication.SetAuthCookie("Anonymous", true); callBackResult = FormsAuthentication.DefaultUrl; WriteLoginLog("Anonymous"); return; } String[] arguments = eventArgument.Split(','); String userAccount = arguments[0]; String password = FormsAuthentication.HashPasswordForStoringInConfigFile(arguments[1], "MD5"); using (SysUserBusiness user = new SysUserBusiness()) { bool passed = user.Authentication(userAccount, password); if (passed) { FormsAuthentication.SetAuthCookie(userAccount, true); HttpCookie authCookie = FormsAuthentication.GetAuthCookie(userAccount, true); FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, ""); authCookie.Value = FormsAuthentication.Encrypt(newTicket); Response.Cookies.Add(authCookie); callBackResult = FormsAuthentication.DefaultUrl; WriteLoginLog(userAccount); } } }
protected void btnLogin_Click(object sender, EventArgs e) { String userAccount = txtUsername.Text.Trim(); String password = txtPassword.Text.Trim(); if (String.IsNullOrWhiteSpace(userAccount) || String.IsNullOrWhiteSpace(password)) { String js = "alert('用户名或密码错误请重新输入!');"; ClientScript.RegisterClientScriptBlock(GetType(), "Msg", js, true); } password = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5"); using (SysUserBusiness user = new SysUserBusiness()) { bool passed = user.Authentication(userAccount, password); if (passed) { FormsAuthentication.SetAuthCookie(userAccount, true); HttpCookie authCookie = FormsAuthentication.GetAuthCookie(userAccount, true); FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, ""); authCookie.Value = FormsAuthentication.Encrypt(newTicket); Response.Cookies.Add(authCookie); callBackResult = FormsAuthentication.DefaultUrl; Server.Transfer(FormsAuthentication.DefaultUrl); } else { String js = "alert('用户名或密码错误请重新输入!');"; ClientScript.RegisterClientScriptBlock(GetType(), "Msg", js, true); } } //FormsAuthentication.SetAuthCookie(userAccount, true); //Server.Transfer(FormsAuthentication.DefaultUrl); }
protected override void OnUnload(EventArgs e) { m_Module.Dispose(); m_Module = null; m_User.Dispose(); m_User = null; base.OnUnload(e); }
protected void btnSave_Click(object sender, EventArgs e) { using (SysUserBusiness Business = new SysUserBusiness()) { String pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtOldPassword.Text, "MD5"); bool passed = Business.Authentication(UserNo, pwd); if (!passed) { ShowMessage("旧密码输入错误请重新输入!"); } if (passed) { pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtConfirmPassword.Text, "MD5"); Business.ChangedPassword(UserNo, pwd); ShowMessage("恭喜你,修改密码成功!"); } } }
protected void btnSave_Click(object sender, EventArgs e) { using (SysUserBusiness Business = new SysUserBusiness()) { String pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtOldPassword.Text, "MD5"); bool passed = Business.Authentication(UserAccount, pwd); if (!passed) { ShowMessage("旧密码输入错误请重新输入!"); } if (passed) { pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtConfirmPassword.Text, "MD5"); Business.ChangedPassword(UserAccount, pwd); ShowMessage("恭喜你,修改密码成功!"); } } }
private void BindUserList() { using (SysUserBusiness user = new SysUserBusiness()) { if (IsAdmin) { UserList.DataSource = user.GetSysUsers(); List <SysUserViewEntity> SysUsers = user.GetSysUsers(); List <RoleMemberEntity> RoleMembers = m_Role.GetRoleMembers(RoleNo); SysUserViewEntity SysUser; foreach (RoleMemberEntity RoleMember in RoleMembers) { SysUser = SysUsers.Where(p => p.UserNo == RoleMember.UserNo).ToList().FirstOrDefault(); SysUsers.Remove(SysUser); } UserList.DataSource = SysUsers; } UserList.DataBind(); } }
public void RaiseCallbackEvent(string eventArgument) { String[] arguments = eventArgument.Split(','); String userAccount = arguments[0]; String password = FormsAuthentication.HashPasswordForStoringInConfigFile(arguments[1], "MD5"); using (SysUserBusiness user = new SysUserBusiness()) { bool passed = user.Authentication(userAccount, password); if (passed) { FormsAuthentication.SetAuthCookie(userAccount, true); HttpCookie authCookie = FormsAuthentication.GetAuthCookie(userAccount, true); FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, ""); authCookie.Value = FormsAuthentication.Encrypt(newTicket); Response.Cookies.Remove(authCookie.Name); Response.Cookies.Add(authCookie); callBackResult = FormsAuthentication.DefaultUrl; } } //FormsAuthentication.SetAuthCookie("Admin", true); //Server.Transfer(FormsAuthentication.DefaultUrl); //callBackResult = FormsAuthentication.DefaultUrl; }
protected override void OnInit(EventArgs e) { m_User = new SysUserBusiness(); base.OnInit(e); }
private void BindUserList() { using (SysUserBusiness user = new SysUserBusiness()) { if (IsAdmin) UserList.DataSource = user.GetSysUsers(); UserList.DataBind(); } }