域密码修改及忘记密码流程系统

说到域大家都并不陌生了,现企业内都有域环境;一般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文件;可以根据自己的真实还行进行修改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?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>

域密码修改及忘记密码流程系统

重置密码流程

域密码修改及忘记密码流程系统

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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 style="height:32px" border="0" cellpadding="0" cellspacing="0">
<tr valign="middle" align="center">
<td>员工编号:</td>
</tr>
</table>
</div>
</td>
<td ;170px">
<input type="text" id="asUserId" style="; height:26px" maxlength="200" />
</td>
<td ;75px">
<input type="button" id="UserSearch" value="Search" class="btnUSearch" />
</td>
</tr>
<tr>
<td valign="bottom" colspan="3" style="height:30px"><span class="spanfont">Iiosoft Account</span>
</td>
</tr>
<tr>
<td colspan="3" class="itcodebg" style="height:44px">
<span id="asitcode">
<table align="center" border="0" cellpadding="0" cellspacing="0" style="height:43px">
<tr align="center">
<td valign="middle" style="font-size:20px; font-family:@Arial Unicode MS;" id="itcodeshow">
</td>
</tr>
</table>
</span>
</td>
</tr>
<tr>
<td colspan="3" valign="bottom" style="height:120px">
<div id="Loading" style="display:none">
<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" style="height:20px">
&nbsp;
</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文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?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会有人回复新密码到该邮箱

域密码修改及忘记密码流程系统

下期我们将通过该功能让域密码跟邮箱密码进行同步




本文转自 高文龙 51CTO博客,原文链接:http://blog.51cto.com/gaowenlong/1343948,如需转载请自行联系原作者

上一篇:WebRTC基础实践 - 1. WebRTC简介


下一篇:spring通过QQ邮箱发送Email