您好,登录后才能下订单哦!
域密码修改及忘记密码流程系统
说到域大家都并不陌生了,现企业内都有域环境;一般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文件;可以根据自己的真实还行进行修改
<?xml version="1.0"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=152368 --> <configuration> <appSettings> <add key="webpages:Version" value="1.0.0.0"/> <add key="ClientValidationEnabled" value="true"/> <add key="UnobtrusiveJavaScriptEnabled" value="true"/> <add key="DomainName" value="iio-dc"></add> <add key="LDAPDomain" value="DC=iiosoft.com,DC=COM"></add> <add key="ConnectionLDAP" value="LDAP://iio-dc/OU=Iio_object,DC=iiosoft,DC=COM"></add> <add key="LDAPAdminUser" value="iiosoft\changepwd"></add> <add key="LDAPAdminPwd" value="password8"></add> <add key="SMTPServer" value="iio-mail01.iiosoft.com"/> <!--<add key="SMTPServer" value="iio-mail01.iiosoft.com"/>--> <add key="ISMail" value="changepwd@iiosoft.com"/> <add key="AdminMail" value="changepwd@iiosoft.com"/> <add key="SMTPUser" value="changepwd@iiosoft.com"/> <add key="SMTPPwd" value="password"/> <add key="EmailDisplayName" value="Change Password System"/> <add key="RollbackURL" value="http://10.10.56.31/Home/PersonProfile"/> </appSettings> <system.web> <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </assemblies> </compilation> <authentication mode="None"> </authentication> <pages> <namespaces> <add namespace="System.Web.Helpers" /> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> <add namespace="System.Web.WebPages"/> </namespaces> </pages> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
重置密码流程
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(); } /// <summary> /// 进入申请密码重置页面 /// </summary> /// <returns></returns> 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<dynamic>" %> <!DOCTYPE html> <html> <head id="Head1" runat="server"> <title>Account Search</title> <link href="../../Content/Site.css" rel="stylesheet" type="text/css" /> </head> <body> <div> <table align="center" border="0" cellpadding="0" cellspacing="0" ;313px"> <tr> <td style=";> <div class="idbg" > <table border="0" cellpadding="0" cellspacing="0"> <tr valign="middle" align="center"> <td>员工编号:</td> </tr> </table> </div> </td> <td ;170px"> <input type="text" id="asUserId" maxlength="200" /> </td> <td ;75px"> <input type="button" id="UserSearch" value="Search" class="btnUSearch" /> </td> </tr> <tr> <td valign="bottom" colspan="3" ><span class="spanfont">Iiosoft Account</span> </td> </tr> <tr> <td colspan="3" class="itcodebg" > <span id="asitcode"> <table align="center" border="0" cellpadding="0" cellspacing="0" > <tr align="center"> <td valign="middle" id="itcodeshow"> </td> </tr> </table> </span> </td> </tr> <tr> <td colspan="3" valign="bottom" > <div id="Loading" > <img src="../img/grid-loading.gif" /><span id="sProcess">加载数据中,请稍后...</span></div> <br /> <input type="button" id="UserConfirm" value="Confirm" class="btnConfirm" /> </td> </tr> <tr> <td colspan="3" valign="bottom" > </td> </tr> <tr> <td colspan="3"> <span class="notes">Note: Have any questions? Please contact IS.</span> <br /> <span class="notes">PhoneNumber: 010-82821000-1000</span> <br /> <span class="notes">Mail: is@Iiosoft.com</span> </td> </tr> </table> </div> </body> </html>
配置web.config文件
<?xml version="1.0"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=152368 --> <configuration> <appSettings> <add key="webpages:Version" value="1.0.0.0"/> <add key="ClientValidationEnabled" value="true"/> <add key="UnobtrusiveJavaScriptEnabled" value="true"/> <add key="DomainName" value="iio-dc"></add> <add key="LDAPDomain" value="DC=iiosoft.com,DC=COM"></add> <add key="ConnectionLDAP" value="LDAP://iio-dc/OU=Iio_object,DC=iiosoft,DC=COM"></add> <add key="LDAPAdminUser" value="iiosoft\changepwd"></add> <add key="LDAPAdminPwd" value="password8"></add> <add key="SMTPServer" value="iio-mail01.iiosoft.com"/> <!--<add key="SMTPServer" value="iio-mail01.iiosoft.com"/>--> <add key="ISMail" value="changepwd@iiosoft.com"/> <add key="AdminMail" value="changepwd@iiosoft.com"/> <add key="SMTPUser" value="changepwd@iiosoft.com"/> <add key="SMTPPwd" value="password"/> <add key="EmailDisplayName" value="Change Password System"/> <add key="RollbackURL" value="http://10.10.56.31/Home/PersonProfile"/> </appSettings> <system.web> <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </assemblies> </compilation> <authentication mode="None"> </authentication> <pages> <namespaces> <add namespace="System.Web.Helpers" /> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> <add namespace="System.Web.WebPages"/> </namespaces> </pages> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
修改完信息后,需要重新生成解决方案
然后我们进行发布;发布后的信息可通过iis部署网站,然后通过iis浏览了
发布默认即可
发布路径:任意地址即可再次:D:\iis\changpwd
发布成功
然后我们安装及打开IIS;添加网站
选择刚才发布的路径:D:\iis\changepwd
为了保证服务正常运行,我更改默认端口80,从80更改8090;同时绑定地址
修改NETframwork的版本,更改为版本4.0
测试结果
我们将通过修改user01、user02的用户进行测试
输入user01的原密码及新密码进行确认
提交确认
修改完成
如果用户忘记自己的密码---Forgot password
输入用户名及收验证码的邮箱,提交
已发送成功
然后查看收到的信息,此时该信息is系统也会说到,当填写相关验证信息后,is会有人回复新密码到该邮箱
下期我们将通过该功能让域密码跟邮箱密码进行同步
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。