Domino 下批量修改Http密码
做为一个Domino管理员太不容易了,为什么这么说呢,我们知道日常的用户帐号的创建、删除等工作会给管理员带来很大困扰,如果创建的用户及需要重置密码等事务多的话管理员成天啥也别干了,干一天估计连吃饭的胃口都没有,那有没有什么好的办法呀!有,那就是通过Domino开发,然后实现批量更改用户的Http密码;具体见下
环境介绍:
Server1:dsgrd-mail01.dsgrd.com
Server2:dsgrd-mail02.dsgrd.com
分别在不同的服务器上注册用户:
2.我们新建一个数据库,然后创建一个表单,然后相关数据进行编辑
3.然后在创建一个试图:
4.将代码填写:
5.代码内容见下:
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim se As New NotesSession
Dim curdoc As NotesDocument
Set curdoc = ws.CurrentDocument.Document
Dim sfile As Variant
sfile = ws.OpenFileDialog(False,"选择一个Excel文件","c:\")
Dim sDomain As String
sDomain = Inputbox("请输入Domain名。")
If sDomain = "" Then
Msgbox "需要输入domain。"
Exit Sub
End If
Dim sUser,sUser2 As String
Dim sdate As String
Dim i As Integer
If Not(Isempty(sfile)) Then
Forall filename In sfile
If Right(filename,4) <> ".xls" Then
Msgbox "请选择Excel文件。"
Exit Sub
End If
Dim oExcel As Variant
Set oExcel = CreateObject ( "Excel.Application" )
Set oWorkbook = oExcel.Workbooks.Open(Cstr(filename))
Set oWorkSheet= oWorkbook.Sheets(1)
Dim namesdb As New notesdatabase(se.CurrentDatabase.Server,"names.nsf")
Dim namesview As notesview
Dim namesdoc As notesdocument
Dim ss As String
Set namesview = namesdb.getview("($VIMPeople)")
i = 2
Dim cs As String
While oWorkSheet.Range ( "A" & Cstr ( i ) ).Value <> ""
sUser = oWorkSheet.Range ( "A" & Cstr ( i ) ).Value
sUser2 = sUser + "/" + sDomain
sdate = oWorkSheet.Range ( "B" & Cstr ( i ) ).Value
Dim doc As notesdocument
Dim username As NotesName,username1 As NotesName
Set username = New NotesName(sUser2)
newpwd = sUser + sdate
Set namesdoc = namesview.getdocumentbykey(Cstr(username.Abbreviated),True)
If namesdoc Is Nothing Then
ss="在通讯录中没有找到"+sUser+"这个用户信息!"
Else
mstring = "@Password('" + newpwd + "')"
namesdoc.HTTPPassword = Evaluate(mstring)
Call namesdoc.save(True,True)
ss=sUser + "的密码被重置为" + newpwd+"。"
End If
cs = cs +Chr(10) +ss
i = i + 1
Wend
Call ws.CurrentDocument.FieldSetText("rtf",cs)
'Msgbox cs
Msgbox "执行完毕。"
End Forall
End If
End Sub
6.保存该数据库,拷贝到服务器的Data目录下:
注意添加权限:给需要执行该数据库的人员添加权限
7.通过notes控制台打开该数据库;首先将该电子表格模板下载后填写需要重置用户户的密码等信息
在用户名下填写需要重置密码的用户名称;在发送邮件日期栏输入用户密码的后半部分:
因为我要求用户重置完密码为用户名+用户发送邮件需要重置的时间
填写后,我们打击上传:
然后输入你当前邮件的网络域名
执行完成;执行后的结果见下