域密碼修改及忘記密碼流程系統(tǒng)
成都創(chuàng)新互聯(lián)主要從事網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)七里河,10余年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來(lái)電咨詢建站服務(wù):18982081108
說(shuō)到域大家都并不陌生了,現(xiàn)企業(yè)內(nèi)都有域環(huán)境;一般50人以上都會(huì)通過(guò)域做管理,這樣比較方便,做應(yīng)用也比較方便,總之管理更方便。今天主要介紹不如部署環(huán)境內(nèi)密碼修改及遺忘密碼流程系統(tǒng)。具體見下:
1. 通過(guò)自己的需求寫代碼:
1》用戶可以通過(guò)員工編號(hào),查詢自己的賬戶‘
2》如果忘記自己的密碼,可以通過(guò)Forgot功能驗(yàn)證信息完成密碼重置
3》通過(guò)該流程系統(tǒng)可修改自己的密碼
環(huán)境介紹:
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
因?yàn)橹拔业拇a已經(jīng)寫完了,代碼就不做詳細(xì)介紹了,我將源代碼共享給大家,如果有興趣可下載并修改使用
首先是要安裝visual studio
在此功能我選擇全部
安裝完成
先安裝mvc
我們先將事先編寫好的程序代碼打開
我們編輯web.conf文件;可以根據(jù)自己的真實(shí)還行進(jìn)行修改
重置密碼流程
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(); } ////// 進(jìn)入申請(qǐng)密碼重置頁(yè)面 /// ///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 = "重置密碼的驗(yàn)證碼已經(jīng)發(fā)送到私人郵箱,請(qǐng)到私人郵箱獲取驗(yàn)證碼提交密碼重置申請(qǐng)。"; 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,您的密碼重置結(jié)果將于24小時(shí)內(nèi)發(fā)送至您的私人郵箱,請(qǐng)注意查收。"; 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.驗(yàn)證所填信息 if (string.IsNullOrEmpty(sname) || string.IsNullOrEmpty(sitCode) || string.IsNullOrEmpty(semployeeNumber)) { Rs = "name and itcode and employee number not be null"; } else { // 2. 驗(yàn)證碼是否正確 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.發(fā)送郵件到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); } } } 修改頁(yè)面信息: <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage " %> Account Search
員工編號(hào): Iiosoft Account
加載數(shù)據(jù)中,請(qǐng)稍后...
Note: Have any questions? Please contact IS.
PhoneNumber: 010-82821000-1000
Mail: is@Iiosoft.com
配置web.config文件
修改完信息后,需要重新生成解決方案
然后我們進(jìn)行發(fā)布;發(fā)布后的信息可通過(guò)iis部署網(wǎng)站,然后通過(guò)iis瀏覽了
發(fā)布默認(rèn)即可
發(fā)布路徑:任意地址即可再次:D:\iis\changpwd
發(fā)布成功
然后我們安裝及打開IIS;添加網(wǎng)站
選擇剛才發(fā)布的路徑:D:\iis\changepwd
為了保證服務(wù)正常運(yùn)行,我更改默認(rèn)端口80,從80更改8090;同時(shí)綁定地址
修改NETframwork的版本,更改為版本4.0
測(cè)試結(jié)果
我們將通過(guò)修改user01、user02的用戶進(jìn)行測(cè)試
輸入user01的原密碼及新密碼進(jìn)行確認(rèn)
提交確認(rèn)
修改完成
如果用戶忘記自己的密碼---Forgot password
輸入用戶名及收驗(yàn)證碼的郵箱,提交
已發(fā)送成功
然后查看收到的信息,此時(shí)該信息is系統(tǒng)也會(huì)說(shuō)到,當(dāng)填寫相關(guān)驗(yàn)證信息后,is會(huì)有人回復(fù)新密碼到該郵箱
下期我們將通過(guò)該功能讓域密碼跟郵箱密碼進(jìn)行同步