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

简介:

说到域大家都并不陌生了,现企业内都有域环境;一般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

image

在此功能我选择全部

image

image

安装完成

image

先安装mvc

image

image

我们先将事先编写好的程序代码打开

image

我们编辑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>

image

重置密码流程

image

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>

image

配置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>

修改完信息后,需要重新生成解决方案

image

然后我们进行发布;发布后的信息可通过iis部署网站,然后通过iis浏览了

image

发布默认即可

image

发布路径:任意地址即可再次:D:\iis\changpwd

image

image

image

发布成功

image

然后我们安装及打开IIS;添加网站

image

选择刚才发布的路径:D:\iis\changepwd

image

为了保证服务正常运行,我更改默认端口80,从80更改8090;同时绑定地址

image

image

image

修改NETframwork的版本,更改为版本4.0

image

测试结果

我们将通过修改user01、user02的用户进行测试

image

输入user01的原密码及新密码进行确认

image

提交确认

image

修改完成

image

如果用户忘记自己的密码---Forgot password

image

输入用户名及收验证码的邮箱,提交

image

已发送成功

image

然后查看收到的信息,此时该信息is系统也会说到,当填写相关验证信息后,is会有人回复新密码到该邮箱

image

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




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

相关文章
|
3月前
|
人工智能 弹性计算 监控
【云故事探索】NO.16:阿里云弹性计算加速精准学 AI 教育普惠落地
全球首个K12教育超级智能体“寒雪老师”依托阿里云弹性计算,实现“超拟人”教学与教育普惠。智能精准学通过AI技术提供个性化学习方案,借助学习机等产品实现语音交互、答疑解惑,助力每个孩子拥有终身学习能力。面对实时交互与流量潮汐挑战,阿里云ECS与GPU算力保障低延迟、高并发服务稳定运行,实现30秒内弹性扩容,确保业务连续性。从实验室到千万课堂,算力支撑寒雪老师从城市到山区,推动AI教育公平发展。
|
12月前
|
Rust 监控 编译器
解密 Python 如何调用 Rust 编译生成的动态链接库(一)
解密 Python 如何调用 Rust 编译生成的动态链接库(一)
264 2
|
11月前
|
SQL 监控 安全
Flask 框架防止 SQL 注入攻击的方法
通过综合运用以上多种措施,Flask 框架可以有效地降低 SQL 注入攻击的风险,保障应用的安全稳定运行。同时,持续的安全评估和改进也是确保应用长期安全的重要环节。
415 71
|
11月前
|
安全 数据安全/隐私保护 开发者
Flask框架的安全性如何?
安全是一个持续的过程,需要不断地关注和更新。随着新的安全威胁的出现和技术的发展,开发者需要及时了解并采取相应的措施来应对,以确保 Flask 应用始终处于安全的状态。
361 63
|
11月前
|
SQL 安全 算法
网络安全与信息安全:关于网络安全漏洞、加密技术、安全意识等方面的知识分享###
本文深入探讨了网络安全与信息安全的重要性,重点分析了网络安全漏洞、加密技术以及安全意识三个方面。通过详细阐述这些方面的基本概念、常见类型、应对措施及实际应用,旨在提升读者对网络安全防护的认识和理解。文章强调,在数字化时代,保障网络安全不仅是技术问题,更是关乎个人隐私、企业机密和国家安全的重要课题。 ###
|
11月前
|
存储 NoSQL 大数据
大数据 数据存储优化
【10月更文挑战第25天】
510 2
|
运维 安全 网络安全
"革新远程访问体验:Docker化部署webssh2,一键启动Web SSH客户端,让远程管理如虎添翼!"
【8月更文挑战第2天】Docker作为软件开发与运维的关键工具,以其轻量级、可移植及强隔离特性简化了应用部署。结合webssh2这一开源Web SSH客户端,可通过浏览器安全便捷地访问SSH服务器,无需额外软件。首先确保已安装Docker,接着拉取webssh2镜像并运行容器,映射端口以便外部访问。配置好SSH服务器后,通过浏览器访问指定URL即可开始SSH会话。此方案不仅提升了用户体验,还加强了访问控制与系统安全。
1021 7
|
机器人 API 开发者
Python基于Mirai开发的QQ机器人保姆式教程(亲测可用)
Python基于Mirai开发的QQ机器人保姆式教程(亲测可用)
|
存储 测试技术 持续交付
【软件设计师】一篇文章让你读懂什么是软件工程与系统开发
【软件设计师】一篇文章让你读懂什么是软件工程与系统开发
|
开发框架 前端开发 JavaScript
学会Web UI框架--Bootstrap,快速搭建出漂亮的前端界面
学会Web UI框架--Bootstrap,快速搭建出漂亮的前端界面
710 0