域密碼修改及忘記密碼流程系統
說到域大家都并不陌生了,現企業內都有域環境;一般50人以上都會通過域做管理,這樣比較方便,做應用也比較方便,總之管理更方便。今天主要介紹不如部署環境內密碼修改及遺忘密碼流程系統。具體見下:
1. 通過自己的需求寫代碼:
1》用戶可以通過員工編號,查詢自己的賬戶‘
2》如果忘記自己的密碼,可以通過Forgot功能驗證信息完成密碼重置
3》通過該流程系統可修改自己的密碼
環境介紹:
Domain:Iiosoft.com
Hostname:Iiosoft-dc
Ip:10.1.1.254
Roles:dc、dns
Hostname:iiosoft-mail01
Ip:10.1.1.11
Roles:domino server
因為之前我的代碼已經寫完了,代碼就不做詳細介紹了,我將源代碼共享給大家,如果有興趣可下載并修改使用
首先是要安裝visual studio
在此功能我選擇全部
安裝完成
先安裝mvc
我們先將事先編寫好的程序代碼打開
我們編輯web.conf文件;可以根據自己的真實還行進行修改
重置密碼流程
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ChangePassword.Models; using System.Web.Caching; namespace ChangePassword.Controllers { public class HomeController : Controller { // // GET: /Home/ public ActionResult Index() { return View(); } public ActionResult ACSearchView() { return View(); } public ActionResult GetYourAccount() { return View(); } public ActionResult FgPasswordView() { return View(); } ////// 進入申請密碼重置頁面 /// ///public ViewResult PersonProfile() { string code = Request["Code"]; ViewBag.Code = ""; if (code != null) { ViewBag.Code = code; } return View(); } public ViewResult ApplySuccess(string type) { if (type == "1") { ViewBag.Msg = "重置密碼的驗證碼已經發送到私人郵箱,請到私人郵箱獲取驗證碼提交密碼重置申請。"; ViewBag.MsgEn = "Authentication code has been sent to the private E-mail, please get the verification code from the private E-mail and submit it"; } else if (type == "2") { ViewBag.Msg = "感謝使用ChangePassword,您的密碼重置結果將于24小時內發送至您的私人郵箱,請注意查收。"; ViewBag.MsgEn = "Thanks to use ChangePassword System, the reset result of your password will be sent to your personal email within 24 hours, please pay attention to check."; } return View(); } public JsonResult ChangePwdApplyFor(string sname, string sitCode, string sdepartment, string semployeeNumber, string stelephone, string smamagerName, string sverificationCode, string random) { string Rs = ""; // 1.驗證所填信息 if (string.IsNullOrEmpty(sname) || string.IsNullOrEmpty(sitCode) || string.IsNullOrEmpty(semployeeNumber)) { Rs = "name and itcode and employee number not be null"; } else { // 2. 驗證碼是否正確 string privateEmail = (string)HttpContext.Cache[sitCode+"_PrivateEmail"]; string verificationCode = (string)HttpContext.Cache[sitCode]; if (string.IsNullOrEmpty(verificationCode) || sverificationCode.Trim() != verificationCode) { Rs = "Verification code have failed"; } else { // 3.發送郵件到IS 郵箱 Mails m = new Mails(); bool s = m.SendMail(sname, sitCode, sdepartment, semployeeNumber, stelephone, smamagerName, privateEmail); if (s) { Rs = "S"; } else { Rs = "F"; } } } return Json(Rs); } public void GetItcode() { string sUserId = Request["sUserId"]; Users u = new Users(); string itcode = u.GetUserItcode(sUserId); Response.Write(itcode.ToString()); } public JsonResult SendFgEmail(string sUserEmail,string sItcode) { Random random = new Random(); string randomCode = random.Next(10000, 99999).ToString(); HttpContext.Cache.Insert(sItcode, randomCode, null, DateTime.Now.AddMinutes(30), Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null); HttpContext.Cache.Insert(sItcode + "_PrivateEmail", sUserEmail, null, DateTime.Now.AddMinutes(30), Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null); Mails m = new Mails(); bool s = m.SendMail(sUserEmail, sItcode, randomCode); string Rs = ""; if (s) { Rs = "S"; } else { Rs = "F"; } return Json(Rs); } //public void SendFgEmail() //{ // string sUserEmail = Request["sUserEmail"]; // string sItcode = Request["sItcode"]; // string sPhone = Request["sPhone"]; // sItcode = sUserEmail.Split('@')[0]; // Mails m = new Mails(); // bool s = m.SendMail(sUserEmail, sItcode, sPhone); // string Rs = ""; // if (s) // { // Rs = "S"; // } // else // { // Rs = "F"; // } // Response.Write(Rs.ToString()); //} public void ChangePwd() { string sItCode = Request["sItCode"]; string sOldPwd = Request["sOldPwd"]; string sNewPwd = Request["sNewPwd"]; ADOperator ao = new ADOperator(); int y = ao.IsUserExistsByAccount(sItCode); string Rs = ""; if (y == 1) { int x = ao.Login(sItCode, sOldPwd); if (x == 1) { int z = ao.ChangeUserPassword(sItCode, sOldPwd, sNewPwd); if (z == 1) { Rs = "CS"; } else { Rs = "TR"; } } else { Rs = "EP"; } } else { Rs = "NU"; } ao.dispose(); Response.Write(Rs.ToString()); } //重置密碼 [HttpGet] public void SetPassword() { string sItCode = Request["sItCode"]; string sNewPwd = Request["sNewPwd"]; ADOperator.SetPasswordByAccount(sItCode, sNewPwd); } } } 修改頁面信息: <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage " %> Account Search
員工編號: Iiosoft Account
加載數據中,請稍后...
Note: Have any questions? Please contact IS.
PhoneNumber: 010-82821000-1000
Mail: is@Iiosoft.com
配置web.config文件
修改完信息后,需要重新生成解決方案
然后我們進行發布;發布后的信息可通過iis部署網站,然后通過iis瀏覽了
發布默認即可
發布路徑:任意地址即可再次:D:\iis\changpwd
發布成功
然后我們安裝及打開IIS;添加網站
選擇剛才發布的路徑:D:\iis\changepwd
為了保證服務正常運行,我更改默認端口80,從80更改8090;同時綁定地址
修改NETframwork的版本,更改為版本4.0
測試結果
我們將通過修改user01、user02的用戶進行測試
輸入user01的原密碼及新密碼進行確認
提交確認
修改完成
如果用戶忘記自己的密碼---Forgot password
輸入用戶名及收驗證碼的郵箱,提交
已發送成功
然后查看收到的信息,此時該信息is系統也會說到,當填寫相關驗證信息后,is會有人回復新密碼到該郵箱
下期我們將通過該功能讓域密碼跟郵箱密碼進行同步
附件:http://down.51cto.com/data/2363911另外有需要云服務器可以了解下創新互聯scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業上云的綜合解決方案,具有“安全穩定、簡單易用、服務可用性高、性價比高”等特點與優勢,專為企業上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。