域密码自助重置系统----绑定私人邮箱信息自助重置(一)

作为一个企业管理员来说,最头疼的事就是用户密码重置工作了;也许跟公司的性质有很大关系,就拿我们公司来说吧!我们企业内部有90%的用户属于外派人员,这些外派人员来说很少有机会访问公司内部资源,所以这些用户的密码容易忘记。由于企业内部的用户账户信息设置最长使用周期是180天,如果在180天没有修改密码,密码将会过期;最主要的是公司内部使用erp系统,用户每个月都要使用自己的用户信息去填写erp,如果不及时填写的话就没有考勤,这样的结果大家都很明白了。当每个月填写考勤的日期,it部门会好几百封邮件做密码重置的;这样给管理员带来太多问题,为了解决这个问题,前面文章有介绍通过web方式批量重置用户的密码,但是这个对于管理员来说是操作方便了,但是解决不了用户的问题,用户的问题就是不更改密码,就是忘记密码后发邮件给it部门让做重置,这样的员工太多了。所以就想通过用户密码自助重置系统来降低管理员的日常工作。

用户通过有效的用户信息登录系统内部,绑定自定义信息后,可以通过绑定的信息自助重置密码。

一、首先是创建安装数据库SQL Server2008,同时创建数据库及表单,在此忽略;

clip_p_w_picpath002

2.创建DBconnection表单,填写数据库的字段信息

clip_p_w_picpath004

using System;
using System.Data;
using System.Data.Odbc;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;
using System.Text;
namespace ChangePassword.Models
{
/// <summary>
/// DataBase Connection Class.
/// </summary>
public class DbConn
{
// Create a database Connection. using here Access Database
// Return type object of OdbcConnection
public OdbcConnection connection;
public OdbcDataReader ReadData;
public OdbcCommand aCommand;
public static string DBConnectionName { get; set; }
public static string DataBaseName { get; set; }
public DbConn()
{
string ConnectionString = ConfigurationManager.AppSettings["dbconnection"].ToString();
try
{
// create connection object
connection = new OdbcConnection();
// set connection string
connection.ConnectionString = ConnectionString;
// open connection
connection.Open();
// get reader
}
catch (Exception e)
{
HttpContext.Current.Response.Write(e.Message.ToString());
}
}
public void ExecuteQuery(string sql)
{
aCommand = new OdbcCommand(sql, connection);
aCommand.ExecuteNonQuery();
}
public DbConn(string strQuery)
{
string ConnectionString = ConfigurationManager.AppSettings["dbconnection"].ToString();
try
{
// create connection object
connection = new OdbcConnection();
// set connection string
connection.ConnectionString = ConnectionString;
// open connection
connection.Open();
// get reader
GetReader(strQuery);
}
catch (Exception e)
{
HttpContext.Current.Response.Write(e.Message.ToString());
}
}
public DbConn(string strQuery,string dbName)
{
// MS Access DataBase Connection - Defined in Web.Config
string connectionName = dbName;//"MSAccessConnectionTD";//"MSAccessConnection";
// SQL Server DataBase Connection - Defined in Web.Config
//string connectionName = "SQLServerConnection";
// Creating Connection string using web.config connection string
string ConnectionString = ConfigurationManager.ConnectionStrings[connectionName].ConnectionString;
try
{
// create connection object
connection = new OdbcConnection();
// set connection string
connection.ConnectionString = ConnectionString;
// open connection
connection.Open();
// get reader
GetReader(strQuery);
}
catch (Exception e)
{
HttpContext.Current.Response.Write(e.Message.ToString());
}
}
// Create an instance dataReader
// Return type object of OdbcDataReader
/// <summary>
/// Get Data Reader
/// </summary>
/// <param name="strQuery">SQL Query</param>
public void GetReader(string strQuery)
{
// Create a Command object
aCommand = new OdbcCommand(strQuery, connection);
// Create data reader object using strQuery string
// Auto close connection
ReadData = aCommand.ExecuteReader(CommandBehavior.CloseConnection);
}
}
}

Web.conf配置数据库连接

clip_p_w_picpath006

新建验证用户信息表单

clip_p_w_picpath008

#region ChangePwdApplyFor绑定邮箱设置
/// <summary>
/// 绑定邮箱设置
/// </summary>
/// <param name="sname">员工姓名</param>
/// <param name="sitCode">员工编号</param>
/// <param name="personalemail">个人邮箱</param>
/// <returns></returns>
public JsonResult ChangePwdApplyFor(string sname, string sitCode, string personalemail)
{
string Rs = "";
// 1.验证所填信息
if (string.IsNullOrEmpty(sname) || string.IsNullOrEmpty(sitCode))
{
Rs = "name and itcode and employee number not be null";
}
else
{
// 2.发送邮件到邮箱
Random random = new Random();
string randomCode = random.Next(10000, 99999).ToString();
HttpContext.Cache.Insert(sitCode + "_bind", randomCode, null, DateTime.Now.AddMinutes(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null);
HttpContext.Cache.Insert(sitCode + "_PrivateEmail", personalemail, null, DateTime.Now.AddMinutes(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null);
Mails m = new Mails();
bool s = m.SendMail(personalemail, sitCode, randomCode, false);
if (s)
{
Rs = "S";
}
else
{
Rs = "F";
}
}
return Json(Rs);
}
#endregion
#region GetItcode根据员工编号获得员工姓名
/// <summary>
///
/// </summary>
public void GetItcode()
{
string sUserId = Request["sUserId"];
Users u = new Users();
string itcode = u.GetUserItcode(sUserId);
Response.Write(itcode.ToString());
}
#endregion
#region GetItcode根据员工编号获得员工姓名
/// <summary>
/// 根据员工编号获得员工姓名
/// </summary>
/// <param name="sUserId">员工编号</param>
/// <returns></returns>
public string GetItcode(string sUserId)
{
Users u = new Users();
string itcode = u.GetUserItcode(sUserId);
if (itcode!=null)
{
Session["sUserId"] = sUserId;
Session["itcode"] = itcode;
}
return itcode.ToString();
}
#endregion
#region BindEmail绑定邮箱并把绑定的邮箱插入数据库
/// <summary>
/// 绑定邮箱并把绑定的邮箱插入数据库
/// </summary>
/// <returns></returns>
public ActionResult BindEmail()
{
string Rs = "";
string sUserEmail = Request["bindemail"];
string sUserId = Request["idcode"];//员工编号
string sItcode = GetItcode(sUserId);
string sverificationCode = Request["code"];//员工姓名
string privateEmail = (string)HttpContext.Cache[sUserId + "_PrivateEmail"];//5930_PrivateEmail
string verificationCode = (string)HttpContext.Cache[sUserId + "_bind"];//5930_bind
if (string.IsNullOrEmpty(verificationCode) || sverificationCode.Trim() != verificationCode)
{
Rs = "Verification code have failed";
return RedirectToAction("ApplySuccess", new { type = 0 });
}
else if (isBindEmail(sUserEmail, sUserId))
{
Rs = "user has been bind";
return RedirectToAction("ApplySuccess", new { type = 3 });
}
else
{
string sql = "insert into userbind values(1,'" + sUserId + "','" + sItcode + "','" + sUserEmail + "','1');";
DbConn conn = new DbConn();
conn.ExecuteQuery(sql);
Rs = "Y";
HttpContext.Cache.Remove(sUserId + "_PrivateEmail");
HttpContext.Cache.Remove(sUserId + "_bind");
return RedirectToAction("ApplySuccess",new {type=4});
}
}
#endregion
#region SendFgEmail判断用户是否已经绑定邮箱
/// <summary>
/// 判断用户是否已经绑定邮箱
/// </summary>
/// <returns></returns>
public JsonResult SendFgEmail() //string sUserEmail,string sUserId
{
string sUserEmail = Request["sUserEmail"];
string sUserId = Request["sItcode"]; //员工编号
string Rs = "";
string sItcode = GetItcode(sUserId);//员工姓名
Mails m = new Mails();
bool isbind = isBindEmail(sUserEmail, sUserId);
if (isbind)
{
Random random = new Random();
string randomCode = random.Next(10000, 99999).ToString();
Session["bindeamil"] = sUserEmail;
HttpContext.Cache.Insert(sItcode+"_code", randomCode, null, DateTime.Now.AddMinutes(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null);
HttpContext.Cache.Insert(sItcode + "_reset_uid", sUserId, null, DateTime.Now.AddMinutes(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null);
HttpContext.Cache.Insert(sItcode + "_reset_uname", sItcode, null, DateTime.Now.AddMinutes(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null);
HttpContext.Cache.Insert(sItcode + "_PrivateEmail", sUserEmail, null, DateTime.Now.AddMinutes(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null);
if (getBindEmail(sItcode).Trim().Equals(sUserEmail.Trim()))
{
Rs = "B";//绑定
bool s = m.SendMail(sUserEmail, sUserId, randomCode, isbind);
}
else
{
Rs = "N"; //邮箱不匹配
}
}
else
{
Rs = "S"; //未绑定
}
return Json(Rs);
}
#endregion
#region getBindEmail根据员工编号获得绑定的邮箱
/// <summary>
/// 根据员工编号获得绑定的邮箱
/// </summary>
/// <param name="sItcode">员工编号</param>//5930
/// <returns></returns>
public string getBindEmail(string sItcode)
{
string bindemail = String.Empty;
string sql = "select bindemail from userbind where username='" + sItcode + "' and isbind=1";
DbConn oRsStatusCount = new DbConn(sql);
while (oRsStatusCount.ReadData.Read())
{
bindemail = oRsStatusCount.ReadData["bindemail"].ToString().Trim();
}
return bindemail;
}
#endregion
#region isBindEmail根据传入的员工编号或邮箱判断是否已经绑定邮箱
/// <summary>
/// 根据传入的员工编号或邮箱判断是否已经绑定邮箱
/// </summary>
/// <param name="sUserEmail">绑定的邮箱</param>
/// <param name="sItcode">员工编号</param>
/// <returns></returns>
public Boolean isBindEmail(string sUserEmail, string sItcode)
{
bool bindflag = false;
string username = GetItcode(sItcode);//员工姓名
string sql = "select count(1) as co from userbind where userid=" + sItcode + " and username='" + username + "' and isbind=1";
DbConn oRsStatusCount = new DbConn(sql);
while (oRsStatusCount.ReadData.Read())
{
int count =(int)(oRsStatusCount.ReadData["co"]);
if (count>0)
{
bindflag = true;
break;
}
else
{
bindflag = false;
}
}
return bindflag;
}
#endregion
#region ChangePwd修改密码
/// <summary>
/// 修改密码
/// </summary>
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";
//调用Domino密码修改
changeDominoPwd(sItCode, sNewPwd);
}
else
{
Rs = "TR";
}
}
else
{
Rs = "EP";
}
}
else
{
Rs = "NU";
}
ao.dispose();
Response.Write(Rs.ToString());
}
#endregion
#region LoginAutheration管理员登陆时判断
/// <summary>
/// 管理员登陆时判断
/// </summary>
public void LoginAutheration()
{
string Rs = "";
string username = Request["username"];
string password = Request["password"];
if (ADOperator.adminlist!=null && ADOperator.adminlist.Contains(username))
{
try
{
DirectoryEntry de = ADOperator.GetDirectoryObject(@iiosoft\" + username, password);
if (de.Name != null)
{
// DirectoryEntry de = ADHelper.GetDirectoryObject(username, password);
//SetPasswordByAccount(de, "user01", "123456abc");
///changeDominoPwd("user01", "123456abc");
Session["admin"] = de;
Rs = "SU";
}
}
catch (Exception)
{
Rs = "CS";
}
}
else
{
Rs = "FA";
}
Response.Write(Rs.ToString());
}
#endregion
#region SetPassword重置密码
/// <summary>
/// 重置密码
/// </summary>
public void SetPassword()
{
string Rs = "";
string sItCode = Request["sItCode"].Trim();
string sNewPwd = Request["sNewPwd"];
string sverificationCode=Request["code"];
string privateEmail = (string)HttpContext.Cache[sItCode + "_PrivateEmail"];
string verificationCode = (string)HttpContext.Cache[sItCode+"_code"];
string uid = (string)HttpContext.Cache[sItCode+"_reset_uid"];
string uname = (string)HttpContext.Cache[sItCode + "_reset_uname"];
if (string.IsNullOrEmpty(verificationCode) || sverificationCode.Trim() != verificationCode.Trim() || !uname.Trim().Equals(sItCode))
{
Rs = "Verification code have failed";
}
else
{
ADOperator ao = new ADOperator();
int y = ao.IsUserExistsByAccount(sItCode);
if (y == 1)
{
string username = ConfigurationManager.AppSettings["AutoRestAdminUser"].ToString(); ;
string password = ConfigurationManager.AppSettings["AutoRestAdminPwd"].ToString(); ;
DirectoryEntry de = ADOperator.GetDirectoryObject(username, password);
//(DirectoryEntry)Session["admin"];
int z = ao.SetPasswordByAccount(de, sItCode, sNewPwd);
if (z == 1)
{
Rs = "CS";
//调用Domino密码修改
changeDominoPwd(sItCode, sNewPwd);
HttpContext.Cache.Remove(sItCode + "_PrivateEmail");
HttpContext.Cache.Remove(sItCode + "_code");
HttpContext.Cache.Remove(sItCode + "_reset_uid");
HttpContext.Cache.Remove(sItCode + "_reset_uname");
string log = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 管理员:" + de.Username.Split('\\')[1] + " 重置用户名: " + sItCode + " 重置密码: " + sNewPwd + " 绑定邮箱: " + privateEmail;
Logger.CheckLog(log);
// System.IO.File.AppendAllText("d:\\IIS2\\userlog.txt", log, Encoding.Default);
}
else
{
Rs = "FA";
}
}
else
{
Rs = "NU";
}
}
Response.Write(Rs.ToString());
}
#endregion
#region Domino密码同步修改
/// <summary>
/// Domino密码同步修改
/// </summary>
/// <param name="sNewUserName"></param>
/// <param name="sNewPwd"></param>
public static void changeDominoPwd(String sNewUserName, String sNewPwd)
{
String serverName = ConfigurationManager.AppSettings["EmailServerName"];
String system_passwd = ConfigurationManager.AppSettings["EmailSystem_passwd"];
String system_username = ConfigurationManager.AppSettings["EmailSystem_username"];
String login_domain = ConfigurationManager.AppSettings["LoginDomainName"];
String cookie = "%temp%/cookie.txt";
String str_login = "cmd.exe /c curl -c " + cookie + " -d \"%25%25ModDate=0FF5136000000000&Username=" + system_username + "&Password=" + system_passwd + "&RedirectTo=%2FChgUpwd.nsf%2Finternetpwd%3FOpenForm\" \"http://" + serverName + "/names.nsf?Login\" ";
String str_changepwd = "cmd.exe /c curl -b " + cookie + " -d \"__Click=0&Form=internetpwd&Time=2013-12-18+19%3A47%3A48&CurLoginUser=CN%3D" + system_username + "%2FO%3D" + login_domain + "&UserName=" + sNewUserName + "&UserPassword=" + sNewPwd + "\" \"http://" + serverName + "/ChgUpwd.nsf/internetpwd?OpenForm&Seq=1\"";
Win32_Process win32 = new Win32_Process();
win32.CreateProcess(str_login);
win32.CreateProcess(str_changepwd);
}
#endregion
}
}

绑定邮箱:

clip_p_w_picpath010

@{
ViewBag.Title = "PersonProfile";
Layout = "~/Views/Shared/_LayoutView.cshtml";
}
@section head{
<script src="@Url.Content("~/Scripts/person-profile.js")" type="text/javascript"></script>
}
<div class="pcontent">
<div class="pstep02">
<b>邮箱绑定</b></div>
<div class="pstep03">
Binding your private e-mail</div>
<div style="letter-spacing: 1.5px; color: #666;">
Verification code is obtained by mail</div>
<ul class="ulstep">
<li class="liTOP"><b>Employee Number</b></li>
<li>
<input id="itCode" name="" type="text" value="@ViewBag.itcode" class="a01input" readonly></li>
<li class="liTOP"><b>Iiosoft Account</b></li>
<li>
<input id="name" name="" type="text" value="@ViewBag.idcode" class="a01input" readonly></li>
<li class="liTOP"><b>Private Mail</b></li>
<li>
<input id="personalemail" name="" value="@ViewBag.bindEmail" type="text" class="a01input">
</li>
<!--li class="liTOP"><b>Department</b></!--li>
<li>
<input id="department" name="" type="text" class="a01input"></li>
<li class="liTOP"><b>Employee Number </b></li>
<!--li
<input id="employeeNumber" name="" type="text" class="a01input"></li>
<li class="liTOP"><b>Telephone</b> </li>
<li>
<input id="telephone" name="" type="text" class="a01input"></li>
<li class="liTOP"><b>Manager name</b> </li>
<li>
<input id="mamagerName" name="" type="text" class="a01input"></li>
<li class="liTOP"><b>Verification Code</b> </li>
<li>
<input id="verificationCode" name="" type="text" value="@ViewBag.Code" class="a01input" readonly></li>
<li></li-->
</ul>
<div class="topw">
<input type="button" id="UserApplyFor" value="Save" class="btnSave" />&nbsp;&nbsp;&nbsp;&nbsp;<input
type="button" id="UserCancel" value="Cancel" class="btnCancel" />
</div>
<div id="Loading3" style="display: none">
<img src="../img/grid-loading.gif" /><span id="sProcess3">更新密码中,请稍后...</span>
</div>
</div>

邮箱验证:

clip_p_w_picpath012

@{
ViewBag.Title = "PersonProfile";
Layout = "~/Views/Shared/_LayoutView.cshtml";
}
@section head{
<script src="@Url.Content("~/Scripts/person-profile.js")" type="text/javascript"></script>
}
<div class="pcontent">
<div class="pstep02">
<b>邮箱验证</b>
</div>
<div class="pstep03">
Change your personal profile
</div>
<div class="pstep04">
A strong personal profile helps prevent
</div>
<div style="letter-spacing: 1.5px; color: #666;">
Verification code is obtained by mail
</div>
<ul class="ulstep">
<li class="liTOP"><b>Name</b></li>
<li>
<input id="name" name="" type="text" class="a01input" value="@ViewBag.idcode" readonly>
</li>
<li class="liTOP"><b>ITcode</b></li>
<li>
<input id="itCode" name="" type="text" value="@ViewBag.idcode" class="a01input" readonly>
</li>
<li class="liTOP"><b>personal email</b></li>
<li>
<input id="personalemail" name="" type="text" class="a01input">
</li>
<li></li>
</ul>
<div class="topw">
<input type="button" id="ValidateEmail" value="Save" class="btnSave" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" id="UserCancel" value="Cancel" class="btnCancel" />
</div>
<div id="Loading3" style="display: none">
<img src="../img/grid-loading.gif" /><span id="sProcess3">更新密码中,请稍后...</span>
</div>
</div>

绑定页面

clip_p_w_picpath014

else if (data == "S") {//绑定页面
location.href = "../Home/PersonProfile?idcode=" + sItcode+ "&bindEmail="+sUserEmail;
return;
}
else {
alert("邮件发送失败,请联系系统管理员.");
$("#backgray").css("display", "none");
closePopup();
return;
}
});
});
});
}
function Reset(i, o, n, r) {
if (i == 0) {
$("#itcode").val("");
}
if (o == 0) {
$("#oldpwd").val("");
}
if (n == 0) {
$("#newpwd").val("");
}
if (r == 0) {
$("#rtpwd").val("");
}
}
function isMail(t) {
//reg = new RegExp('^[a-zA-Z0-9]+@[a-zA-Z0-9]+.[a-z][a-z.]{2,8}$');
var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if (myreg.test(t)) {
return true;
// if (t.indexOf("Iiosoft") >= 0) {
// return true;
// }
// else {
// return false;
// }
} else {
return false;
}
}
function ChangePwd() {
$("#Loading3").css("display", "");
var sItCode = $.trim($("#itcode").val());
var sOldPwd = $.trim($("#oldpwd").val());
var sNewPwd = $.trim($("#newpwd").val());
var sRtPwd = $.trim($("#rtpwd").val());
if (sItCode == "") {
alert("请输入用户账号.");
Reset(0, 0, 0, 0);
return;
}
if (sRtPwd != sNewPwd) {
alert("两次输入密码不相同,请重新输入.");
Reset(1, 1, 0, 0);
return;
}
$.post(
"../Home/ChangePwd",
{ sItCode: sItCode, sOldPwd: sOldPwd, sNewPwd: sNewPwd, random: Math.random() },
function (data) {
$("#Loading3").css("display", "none");
if (data != "") {
if (data == "CS") {
alert("用户密码修改成功.");
Reset(0, 0, 0, 0);
//window.location.href = "http://iio-mail01/ChgUpwd.nsf/internetpwd?OpenForm";
} //忘了user01 de 密码。。
else if (data == "TR") {
alert("新密码不满足密码策略,请重新输入使新密码满足最小密码长度8位、密码复杂性和历史密码5次不重复的要求!");
Reset(1, 1, 0, 0);
}
else if (data == "EP") {
alert("错误的登录密码.");
Reset(1, 0, 0, 0);
}
else if (data == "NU") {
alert("用户不存在.");
Reset(0, 0, 0, 0);
}
return;
}
else {
alert("系统出错,请联系系统管理员.");
return;
}
});
}
function adminLogin() {
$("#Loading3").css("display", "");
var username = $.trim($("#username").val());
var password = $.trim($("#password").val());
if (username == "") {
alert("请输入用户账号.");
Reset(0, 0, 0, 0);
return;
}
if (password == "") {
alert("请输入密码.");
Reset(1, 1, 0, 0);
return;
}
$.post(
"../Home/LoginAutheration",
{ username: username, password: password, random: Math.random() },
function (data) {
$("#Loading3").css("display", "none");
if (data != "") {
if (data == "CS") {
alert("用户密码错误.");
Reset(0, 0, 0, 0);
} else if (data == "FA") {
alert("当前用户没有权限.");
Reset(0, 0, 0, 0);
} else if (data == "SU") {
window.location.href = "../Home/resetpwd"
}
return;
}
else {
alert("系统出错,请联系系统管理员.");
return;
}
});
}
function ResetSinglePwd() {
$("#Loading3").css("display", "");
var sItCode = $.trim($("#itcode").val());
var sOldPwd = "123";
var sNewPwd = $.trim($("#newpwd").val());
var sRtPwd = $.trim($("#rtpwd").val());
var code = $.trim($("#code").val());
if (sItCode == "") {
alert("请输入用户账号.");
Reset(0, 0, 0, 0);
return;
}
if (sRtPwd != sNewPwd) {
alert("两次输入密码不相同,请重新输入.");
Reset(1, 1, 0, 0);
return;
}
$.post(
"../Home/SetPassword",
{ sItCode: sItCode, sOldPwd: sOldPwd, sNewPwd: sNewPwd, code:code,random: Math.random() },
function (data) {
$("#Loading3").css("display", "none");
if (data != "") {
if (data == "CS") {
alert("用户密码修改成功.");
Reset(0, 0, 0, 0);
} //忘了user01 de 密码。。
else if (data == "TR") {
alert("新密码不满足密码策略,请重新输入使新密码满足最小密码长度8位、密码复杂性和历史密码5次不重复的要求!");
Reset(1, 1, 0, 0);
}
else if (data == "EP") {
alert("错误的登录密码.");
Reset(1, 0, 0, 0);
}
else if (data == "NU") {
alert("用户不存在.");
Reset(0, 0, 0, 0);
}
else if (data == "Verification code have failed")
{
location.href = "../Home/ApplySuccess?type=5";
}
return;
}
else {
alert("系统出错,请联系系统管理员.");
return;
}
});
}
function ResetAllPwd() {
$("#Loading3").css("display", "");
var sItCodes = $.trim($("#itallcode").val());
if (sItCodes == "") {
alert("请输入用户账号.");
Reset(0, 0, 0, 0);
return;
}
$.post(
"../Home/SetAllPassword",
{ sItCodes: sItCodes, random: Math.random() },
function (data) {
$("#Loading3").css("display", "none");
if (data != "") {
if (data == "CS") {
alert("用户密码修改成功.");
Reset(0, 0, 0, 0);
$("#itallcode").attr("value", "");
} //忘了user01 de 密码。。
else if (data == "TR") {
alert("新密码不满足密码策略,请重新输入使新密码满足最小密码长度8位、密码复杂性和历史密码5次不重复的要求!");
Reset(1, 1, 0, 0);
}
else if (data == "EP") {
alert("错误的登录密码.");
Reset(1, 0, 0, 0);
}
else if (data == "NU") {
alert("用户不存在.");
Reset(0, 0, 0, 0);
}
return;
}
else {
alert("系统出错,请联系系统管理员.");
return;
}
});
}

重置密码:

clip_p_w_picpath016

@{
ViewBag.Title = "Resetpwd";
Layout = "~/Views/Shared/_LayoutView.cshtml";
}
@section head{
<script src="@Url.Content("~/Scripts/home.js")" type="text/javascript"></script>
}
<div id="contactArea">
</div>
<div class="pcontent">
<div class="pstep02">
<b>重置密码</b>
</div>
<div class="pstep03">
Change your password
</div>
<div class="pstep04">
A strong password helps prevent
</div>
<div id="resetsingle">
<ul class="ulstep">
<input name="" id="code" type="hidden" value="@ViewBag.Code" />
<li><b>Iiosoft Account</b> <!--a style="cursor: pointer;" id="Search">What's this?</!a--></li>
<li>
<input name="" id="itcode" type="text" value="@ViewBag.name" readonly class="a01input" />
</li>
<li class="liTOP"><b>New password </b></li>
<li>
<input name="" id="newpwd" type="password" class="a01input" />
</li>
<li style="color: #999;">8-character minimum; case sensitive </li>
<li class="liTOP"><b>Recenter password </b></li>
<li>
<input name="" id="rtpwd" type="password" class="a01input" />
</li>
</ul>
<div class="topw">
<input type="button" id="UserSetSinglepwd" value="Save" class="btnSave" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" id="UserpwdCancel" value="Cancel" class="btnCancel" />
</div>
</div>
<div id="Loading3" style="display: none">
<img src="../img/grid-loading.gif" /><span id="sProcess3">更新密码中,请稍后...</span>
</div>
</div>

本地log生成记录

clip_p_w_picpath018

通过自助系统忘记密码

clip_p_w_picpath020

填写需要重置的用户信息、及私人邮箱

clip_p_w_picpath022

邮箱绑定

clip_p_w_picpath024

将绑定信息发送私人邮箱,进行绑定

clip_p_w_picpath026

私人邮箱收到的绑定信息,绑定确认链接

clip_p_w_picpath028

通过访问该链接进行绑定

clip_p_w_picpath030

绑定信息后,进行重置

clip_p_w_picpath022[1]

提交后,重置信息将发送到绑定的私人邮箱中,进行重置

clip_p_w_picpath032

绑定的私人邮箱会收到一封邮件进行重置

clip_p_w_picpath034

重置用户信息,用户只需要输入新密码即可

clip_p_w_picpath036

重置后,我们可以在数据库下 查看绑定的信息

绑定后,我们可以在数据库下查看绑定后的信息

//查询resetpasswd数据库下dbo.userbind的绑定信息

select * from resetpasswd.dbo.userbind

//删除resetpasswd数据库下dbo.userbind的绑定信息

delete from changepassword.dbo.questioninfo where id in (1)

clip_p_w_picpath038

重置后在本地生成log文件:

clip_p_w_picpath040

clip_p_w_picpath042