public static string OnSignin(string user, string pwd, bool remember) { var serviceClient = new SmartHsServiceClient(); var result = serviceClient.Login(user, pwd, GetRequestIp(), 1); var jObj = JObject.Parse(result); if (Convert.ToInt32(jObj["Code"]) == 1) { HttpContext.Current.Session["UserName"] = user; if (remember) { var memberCookie = HttpContext.Current.Request.Cookies["CurrentMember"]; if (memberCookie == null || !memberCookie.Values["user"].Equals(user)) { memberCookie = new HttpCookie("CurrentMember"); memberCookie.Values.Add("user", user); memberCookie.Values.Add("pwd", SecurityEncryption.EncryptDefault(pwd)); memberCookie.Expires = DateTime.Now.AddDays(7); HttpContext.Current.Response.Cookies.Add(memberCookie); } } } return(result); }
protected void btnSure_Click(object sender, EventArgs e) { User bllUser = new User(); int id = 0; try { id = (int)SessionBox.GetUserSession().LoginId; } catch (Exception ex) { JSHelper.AlertAndRedirect("请登录后操作!\n" + ex.Message, "../Login.aspx", this); } if (bllUser.VerifyPassword(id, SecurityEncryption.MD5(txtOldPwd.Text, 32))) { if (bllUser.ChangePassword(id, SecurityEncryption.MD5(txtPwd2.Text, 32))) { JSHelper.AlertAndRedirect("密码修改成功,下次登录请用新密码!", "../Main.aspx", this); } } else { JSHelper.Alert("原密码输入不正确!", this); } }
public static string PostWithSign(string url, string json, string appid, string secretkey) { HttpContent content; if (!string.IsNullOrWhiteSpace(json)) { var _json = (JObject)JsonConvert.DeserializeObject(json); _json.AddFirst(new JProperty("sign", SecurityEncryption.MD5_Encrypt_String(json + secretkey))); _json.AddFirst(new JProperty("appid", appid)); content = new StringContent(JsonConvert.SerializeObject(_json), Encoding.UTF8); } else { content = new StringContent(JsonConvert.SerializeObject(new { appid = appid, sign = SecurityEncryption.MD5_Encrypt_String("{}" + secretkey) }), Encoding.UTF8); } content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var hclient = new HttpClient(); hclient.Timeout = new System.TimeSpan(1, 0, 0, 0, 0); var hresponse = hclient.PostAsync(url, content); var response_result = hresponse.Result; return(response_result.Content.ReadAsStringAsync().Result); }
protected void btnSure_Click(object sender, EventArgs e) { User bllUser = new User(); if (bllUser.ChangePassword(Convert.ToInt32(Request.QueryString["userid"]), SecurityEncryption.MD5(txtPwd.Text, 32))) { JSHelper.CloseWindow(); } }
private void ShowInfo(int bId) { PaducnSoft.Model.ay_admin model = dal.GetModel(bId); this.bId.Value = model.bId.ToString(); this.bName.Text = model.bName; this.bName.Enabled = false; this.bRealName.Text = model.bRealName; this.bPassword.Attributes.Add("Value", SecurityEncryption.DESDecrypt(model.bPassword)); this.bOrder.Value = model.bOrder.ToString(); this.bRemark.Text = model.bRemark; }
public void ProcessRequest(HttpContext context) { //context.Response.ContentType = "text/plain"; //context.Response.Write("Hello World"); var sessionCookieValue = context.Request.Form["code"]; context.Response.ContentType = "text/plain"; //context.Response.Write("This is plain text"); if (sessionCookieValue == null) { context.Response.Write("False"); context.Response.End(); } string decryptedCookieValue = null; try { decryptedCookieValue = SecurityEncryption.Decrypt(sessionCookieValue); } catch { context.Response.Write("False"); context.Response.End(); } if (decryptedCookieValue == null) { context.Response.Write("False"); context.Response.End(); } else { var applicationCookieValue = context.Application[decryptedCookieValue]; if (applicationCookieValue == null) { context.Response.Write("False"); context.Response.End(); } context.Response.Write($"{applicationCookieValue}{decryptedCookieValue}"); } context.Response.End(); }
protected void btnSubmit_Click(object sender, EventArgs e) { string strErr = ""; if (this.bName.Text.Trim().Length == 0) { strErr += "用户不能为空!\\n"; } if (this.bPassword.Text.Trim().Length == 0) { strErr += "密码不能为空!\\n"; } if (strErr != "") { MessageBox.Alert(this, strErr); return; } PaducnSoft.Model.ay_admin model = new PaducnSoft.Model.ay_admin(); model.bId = (int)StringPlus.ConvertNullToZero(this.bId.Value); model.bName = this.bName.Text; model.bRealName = this.bRealName.Text; model.bPassword = SecurityEncryption.DESEncrypt(this.bPassword.Text.ToString().Trim()); model.bOrder = (int)StringPlus.ConvertNullToZero(this.bOrder.Value); model.bAddTime = DateTime.Now; model.bRemark = this.bRemark.Text; model.bAddUser = paducncms.Module.UserRights.AdminUserID; StringBuilder strWhere = new StringBuilder(); strWhere.AppendFormat(" and bId<>{0}", this.bId.Value); strWhere.AppendFormat(" and bName='{0}'", model.bName); if (dal.Exists(strWhere.ToString())) { MessageBox.Alert(this, "名称已存在,请重新输入!"); return; } bool result = dal.Update(model); if (result) { MessageBox.Alert(this, "更新成功!", "default.aspx"); } else { MessageBox.Alert(this, "更新失败!"); } }
protected void btnAddPerson_Click(object sender, EventArgs e) { User usersCrud = new User(); SF_User user = new SF_User(); if (txtPwd.Text != "" && ddlUserGroup.SelectedValue != "-1") { int usercount = 0; string userName = ""; user.PassWord = SecurityEncryption.MD5(txtPwd.Text.Trim(), 32); int roleID = 0; roleID = Convert.ToInt32(ddlRole.SelectedValue); user.UserGroupID = Convert.ToInt32(ddlUserGroup.SelectedValue); user.UserStatus = ddlState.SelectedValue; for (int i = 0; i < xlstSelected.Items.Count; i++) { user.UserName = xlstSelected.Items[i].Value.ToString(); user.PersonNumber = xlstSelected.Items[i].Value.ToString(); if (!usersCrud.UserExists(user.UserName)) { int n = (int)usersCrud.CreateUser(user); if (n >= 1) { if (roleID != 0) { usersCrud.AddUserRole(n, roleID); } } usercount++; } else { userName += user.UserName + ","; } } JSHelper.Alert(string.Format("共添加{0}个用户!", usercount), this); } else { JSHelper.Alert("初始化信息请填写完整!", this); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //if (string.IsNullOrEmpty(Request.QueryString["mark"])) //{ // DBSCMDataContext dc = new DBSCMDataContext(); // var mark = dc.Loginmark.First(); // //string serverAddr = "http://" + (mark.Lmark == 0 ? "zcpt.54321.cn/" : "10.1.10.74:81/") + "login.aspx?mark=" + mark.Lmark.ToString(); // string serverAddr = "http://{0}login.aspx?mark=" + mark.Lmark.ToString(); // string[] serverIp = new string[] { "zcpt.54321.cn/", "10.1.10.74:81/", "10.1.10.73/" }; // serverAddr = string.Format(serverAddr, serverIp[(int)(mark.Lmark)]); // mark.Lmark = (mark.Lmark + 1) % 3; // dc.SubmitChanges(); // if (Request.Params["txtName"] != null && Request.Params["txtPwd"] != null) // { // serverAddr += "&txtName=" + Request.Params["txtName"].ToString().Trim() + "&txtPwd=" + Request.Params["txtPwd"].ToString().Trim(); // } // Response.Redirect(serverAddr, true); //} //LicHelper.LicHelper lic = new LicHelper.LicHelper(); //if (lic.HasLic()) //{ if (Request.Params["txtName"] != null && Request.Params["txtPwd"] != null) { LoginVerify(Request.Params["txtName"].ToString().Trim(), SecurityEncryption.MD5(Request.Params["txtPwd"].ToString().Trim(), 32)); } else { txtUserName.Focus(); } //} //else //{ // //JSHelper.("UpdateLic.aspx",800,500,100,200,this); // Response.Redirect("UpdateLic.aspx",true); //} } }
public void ProcessRequest(HttpContext context) { const string cookieTest = "cookietest"; var cookie = context.Request.Cookies[cookieTest]; if (cookie != null) { var value = cookie.Value; var encrypedValue = SecurityEncryption.Encrypt(value); cookie.Expires = DateTime.Now.AddDays(-1); context.Response.Cookies.Add(cookie); context.Application.Lock(); context.Application[value] = encrypedValue; context.Application.UnLock(); context.Response.Write(encrypedValue); context.Response.End(); } }
/// <summary>获得请求登陆用户状态签名</summary> /// <param name="loginId"></param> /// <param name="relyingName"></param> /// <param name="signing"></param> /// <returns></returns> public static string GetLoginSign(string loginId, string relyingName, string signing) { return(SecurityEncryption.MD5_Encrypt_String(string.Format("{0}-{1}-{2}", (object)loginId, (object)relyingName, (object)signing))); }
protected void btnSure_Click(object sender, EventArgs e) { if (upctrlPsn.UploadedFiles[0].IsValid && upctrlPsn.HasFile) { commonFunc.SaveFile(upctrlPsn, this); string savePath = commonFunc.GetSavePath(upctrlPsn, this); Aspose.Cells.Workbook xlsPsn = new Aspose.Cells.Workbook(savePath); //xlsPsn.Open(savePath); Aspose.Cells.Cells cellsPsn = xlsPsn.Worksheets[0].Cells; var dtTemp = cellsPsn.ExportDataTable(0, 0, cellsPsn.MaxDataRow + 1, cellsPsn.MaxDataColumn + 1); User usersCrud = new User(); SF_User user = new SF_User(); if (ddlUserGroup.SelectedValue != "-1" && ddlRole.SelectedValue != "-1") { int usercount = 0; int usercount2 = 0; string userName = ""; user.PassWord = SecurityEncryption.MD5("123456", 32); int roleID = 0; roleID = Convert.ToInt32(ddlRole.SelectedValue); user.UserGroupID = Convert.ToInt32(ddlUserGroup.SelectedValue); for (int i = 1; i < dtTemp.Rows.Count; i++) { user.UserName = dtTemp.Rows[i][0].ToString().Trim(); user.PersonNumber = dtTemp.Rows[i][0].ToString().Trim(); if (!usersCrud.UserExists(user.UserName)) { int n = (int)usersCrud.CreateUser(user); if (n >= 1) { if (roleID != 0) { usersCrud.AddUserRole(n, roleID); } } usercount++; } else { if (cellsPsn.Columns.Count >= 3 && dtTemp.Rows[i][3].ToString().Trim() != "") { SF_User user2 = usersCrud.GetUserModel(user.UserName); user2.UserName = dtTemp.Rows[i][3].ToString().Trim(); int n2 = (int)usersCrud.UpdateUser(user2); if (n2 >= 1) { usercount2++; } } userName += user.UserName + ","; } } commonFunc.DeleteFile(savePath); JSHelper.Alert(string.Format("共添加{0}个用户!共更新{1}个用户!", usercount, usercount2), this); } else { JSHelper.Alert("初始化信息请填写完整!", this); } } }
protected void ibtnLogin_Click(object sender, ImageClickEventArgs e) { LoginVerify(txtUserName.Text.Trim(), SecurityEncryption.MD5(txtPwd.Text.Trim(), 32)); }