近期呢,公司有一个分布将近有700左右的人员,均需要重置一下一邮箱密码,重置密码简单,可人数众多,如果管理员通过手动的方式一个一个重置会给管理员带来很大困扰,同时密码要求重置成不不同的密码,如果将所有用户密码重置成一个密码就方便很多,所以就想到了通过web程序来实现批量重置邮箱密码,做完后,效果还不错,再此分享给大家,供参考学习。
密码重置要求是用户名+***后6位;通过web方式重置用户密码的格式要求是:用户名,密码的方式
我们首先在notes下创建一个空数据库
为数据库命名:Changepwd.nsf
创建好后,我们通过desinger打开该数据库
因为我们开始已经定义了web的排版页面,所以首先是创建一个表单
表单名称:pwd
设置自己的页面格式:具体参考见下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
< div style = "display:none" >
</ div >
< div style = "text-align:center" >
< h1 >邮箱密码重置系统< h1 >
</ div >
< table border = "1" cellspacing = "0" align = "center" style = ";text-align:center" >
< tr >
< td >Tip</ td >
< td >请按照以下格式进行填写:username,password</ td >
</ tr >
< tr >
< td >用户名+密码:</ td >
< td ></ td >
</ tr >
< tr >
< td colspan = "2" align = "center" >
</ td >
</ tr >
</ table >
|
将代码写好后,我们保存
用户名域值属性---文本、多值
输入的参数通过新行来区分
调整页面大小
添加一个重置按钮
重置密码的表单已经完成。
重置密码程序:---新建代理agtpwd
编辑程序
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
|
% REM
Agent 修改用户名密码 Created 2013-12-15 by administrator/iiosoft Description: Comments for Agent %END REM
Option Public
Option Declare
Dim session As NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim namesdb As NotesDatabase
Dim namesdoc As NotesDocument
Dim namesview As NotesView
Sub Initialize
On Error GoTo err_handle
Dim flag As Boolean
Dim mstring As String
Dim arr As Variant
Set session = New NotesSession
Set db = session.Currentdatabase
Set doc = session.Documentcontext
Set namesdb = New NotesDatabase( "" , "names.nsf" )
flag = False
If Not namesdb.Isopen Then
MsgBox "您无权限修改,请联系管理员"
Print |<script type= 'text/javascript'>
alert( "您无权限修改,请联系管理员" ");
window.location = "http://iio-mail01.iiosoft.com/ChgUpwd.nsf/|+doc.Form(0)+|?OpenForm" ;
</script>| Exit sub
End If
Set namesview = namesdb.Getview( "People" )
ForAll msg In doc.username
Call fnChangeUserPwd(msg)
End ForAll
Print |<a href = "/| & doc.dbpath(0) & |/pwd?openform" >click here To Return |
Exit Sub
err_handle: MsgBox session.Currentdatabase.Filepath + session.Currentagent.name MsgBox Error
MsgBox Erl End Sub
% REM
Sub fnChangeUserPwd
Description: Comments for Sub
%END REM
Sub fnChangeUserPwd(msg As String )
On Error GoTo eh
Dim namedoc As NotesDocument
Dim user As String
Dim pwd As String
If msg= "" Then
Exit sub
End If
user=StrLeft(msg, "," )
pwd=StrRight(msg, "," )
Set namedoc=namesview.Getdocumentbykey(user, true)
If Not namedoc Is Nothing Then
namedoc.HTTPPassword = Evaluate(|@Password( "| & pwd &|" )|)
namedoc. HTTPPasswordChangeDate = Now Call namedoc.save( True , True )
Print "change user : " & user & " password :" & pwd & " ,Rest success <br>"
Else Print "can not find user: " & user & "<br>"
End If
Exit Sub
eh: MsgBox Error & " " & erl
End Sub
|
1
2
3
4
5
6
7
|
% REM
Agent 修改用户名密码 Created 2013-12-15 by administrator/iiosoft Description: Comments for Agent %END REM
Option Public
Option Declare
|
1
2
3
4
5
6
|
Dim session As NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim namesdb As NotesDatabase
Dim namesdoc As NotesDocument
Dim namesview As NotesView
|
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
|
Sub Initialize
On Error GoTo err_handle
Dim flag As Boolean
Dim mstring As String
Dim arr As Variant
Set session = New NotesSession
Set db = session.Currentdatabase
Set doc = session.Documentcontext
Set namesdb = New NotesDatabase( "" , "names.nsf" )
flag = False
If Not namesdb.Isopen Then
MsgBox "您无权限修改,请联系管理员"
Print |<script type= 'text/javascript'>
alert( "您无权限修改,请联系管理员" ");
window.location = "http://iio-mail01.iiosoft.com/ChgUpwd.nsf/|+doc.Form(0)+|?OpenForm" ;
</script>| Exit sub
End If
Set namesview = namesdb.Getview( "People" )
ForAll msg In doc.username
Call fnChangeUserPwd(msg)
End ForAll
Print |<a href = "/| & doc.dbpath(0) & |/pwd?openform" >click here To Return |
Exit Sub
err_handle: MsgBox session.Currentdatabase.Filepath + session.Currentagent.name MsgBox Error
MsgBox Erl End Sub
|
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
|
% REM
Sub fnChangeUserPwd
Description: Comments for Sub
%END REM
Sub fnChangeUserPwd(msg As String )
On Error GoTo eh
Dim namedoc As NotesDocument
Dim user As String
Dim pwd As String
If msg= "" Then
Exit sub
End If
user=StrLeft(msg, "," )
pwd=StrRight(msg, "," )
Set namedoc=namesview.Getdocumentbykey(user, true)
If Not namedoc Is Nothing Then
namedoc.HTTPPassword = Evaluate(|@Password( "| & pwd &|" )|)
namedoc. HTTPPasswordChangeDate = Now Call namedoc.save( True , True )
Print "change user : " & user & " password :" & pwd & " ,Rest success <br>"
Else Print "can not find user: " & user & "<br>"
End If
Exit Sub
eh: MsgBox Error & " " & erl
End Sub
|
代码标记好后,我们需要通过表单来调用程序
查看服务器信息
输入需要重置的用户及密码进行重置密码
重置完成后,我们可以看见操作的log
重置后,还可以单击跳转页面进行跳转到密码重置首页
重置后,我们通过控制台来验证密码是否重置成功
注:数据库上传到页面上了,下载附件后,将扩展名更改为.7z后才能解压。
本文转自 高文龙 51CTO博客,原文链接:http://blog.51cto.com/gaowenlong/1561185,如需转载请自行联系原作者