Sub Initialize
%REM
功能:实现用户修改密码功能,每个用户只能修改自己的用户
%END REM
On Error Goto UnknowError
Dim session As New NotesSession
Dim userDB As NotesDatabase
Dim userView As NotesView
Dim view As NotesView
Dim userDc As NotesDocumentCollection
Dim nameDoc As NotesDocument
Dim strShortName As String
Dim nametmp As String
Dim nameStr As String
Dim queryStr As String
Set doc=session.DocumentContext
Set userDB=session.GetDatabase("","Names.nsf")
%REM
Set userView=userDB.GetView("hvPeople")
Set userDc=userView.GetAllDocumentsByKey(doc.writer(0),True)
Set userDoc=userView.GetDocumentByKey(doc.writer(0),True)
%END REM
queryStr={select form="Person" & @Contains(FullName;"} & doc.writer(0) & {")}
Set userDc=userDB.Search(queryStr,Nothing,0)
If userDc.Count=0 Then
Print {<script>alert("更改不成功:/n没有找到您的注册信息!");window.close();</script>}
Exit Sub
End If
Set userDoc=userDc.GetFirstDocument
If Not userDoc Is Nothing Then
nametmp=userDoc.ShortName(0)
pswtmp=userDoc.HTTPPassword(0)
oldpswtmp=Evaluate( {@Password(oldpsw)}, doc)
If Not session.VerifyPassword(doc.oldpsw(0),pswtmp) Then
Print {<script>alert("更改不成功:/n输入的旧口令不对!");window.close();</script>}
Print {<script>window.navigate("changePassword?openForm")</script>}
Exit Sub
End If
newpswtmp=Evaluate("@Password('"+doc.newpsw(0) +"')")
confirmpsw=Evaluate("@Password('"+doc.confirmpsw(0) +"')")
If newpswtmp(0)<>confirmpsw(0) Then
Print {<script>alert("两次输入的新密码不一致,请重新输入!");window.close();</script>}
Print {<script>window.navigate("changePassword?openForm")</script>}
Exit Sub
End If
Call userDoc.ReplaceItemValue("HTTPPassword",newpswtmp )
Call userDoc.Save(True,True)
Call userDB.UpdateFTIndex(True)
Print {<script>alert("更改成功:/n口令修改成功,关闭所有IE窗口,下次登录时,口令生效!");history.go(-1)</script>}
Print {<script>window.navigate("changePassword?openForm")</script>}
'************增加系统日志***************************************************************************
Dim nameItem As NotesName
Set nameItem =New NotesName(session.EffectiveUserName)
Call AddEventLog("修改密码","密码管理","业务日志",nameItem.Common & "修改密码")
End If
Set view = userDB.GetView("($Users)")
If Not view Is Nothing Then
Call view.Refresh
End If
Set view = userDB.GetView("($ServerAccess)")
If Not view Is Nothing Then
Call view.Refresh
End If
'向控制台输入命令
Call session.SendConsoleCommand("",{sh nlcache reset})
Exit Sub
UnknowError:
Msgbox "修改密码错误行:" & Erl & "错误信息:" & Error
Exit Sub
End Sub
%REM
功能:实现用户修改密码功能,每个用户只能修改自己的用户
%END REM
On Error Goto UnknowError
Dim session As New NotesSession
Dim userDB As NotesDatabase
Dim userView As NotesView
Dim view As NotesView
Dim userDc As NotesDocumentCollection
Dim nameDoc As NotesDocument
Dim strShortName As String
Dim nametmp As String
Dim nameStr As String
Dim queryStr As String
Set doc=session.DocumentContext
Set userDB=session.GetDatabase("","Names.nsf")
%REM
Set userView=userDB.GetView("hvPeople")
Set userDc=userView.GetAllDocumentsByKey(doc.writer(0),True)
Set userDoc=userView.GetDocumentByKey(doc.writer(0),True)
%END REM
queryStr={select form="Person" & @Contains(FullName;"} & doc.writer(0) & {")}
Set userDc=userDB.Search(queryStr,Nothing,0)
If userDc.Count=0 Then
Print {<script>alert("更改不成功:/n没有找到您的注册信息!");window.close();</script>}
Exit Sub
End If
Set userDoc=userDc.GetFirstDocument
If Not userDoc Is Nothing Then
nametmp=userDoc.ShortName(0)
pswtmp=userDoc.HTTPPassword(0)
oldpswtmp=Evaluate( {@Password(oldpsw)}, doc)
If Not session.VerifyPassword(doc.oldpsw(0),pswtmp) Then
Print {<script>alert("更改不成功:/n输入的旧口令不对!");window.close();</script>}
Print {<script>window.navigate("changePassword?openForm")</script>}
Exit Sub
End If
newpswtmp=Evaluate("@Password('"+doc.newpsw(0) +"')")
confirmpsw=Evaluate("@Password('"+doc.confirmpsw(0) +"')")
If newpswtmp(0)<>confirmpsw(0) Then
Print {<script>alert("两次输入的新密码不一致,请重新输入!");window.close();</script>}
Print {<script>window.navigate("changePassword?openForm")</script>}
Exit Sub
End If
Call userDoc.ReplaceItemValue("HTTPPassword",newpswtmp )
Call userDoc.Save(True,True)
Call userDB.UpdateFTIndex(True)
Print {<script>alert("更改成功:/n口令修改成功,关闭所有IE窗口,下次登录时,口令生效!");history.go(-1)</script>}
Print {<script>window.navigate("changePassword?openForm")</script>}
'************增加系统日志***************************************************************************
Dim nameItem As NotesName
Set nameItem =New NotesName(session.EffectiveUserName)
Call AddEventLog("修改密码","密码管理","业务日志",nameItem.Common & "修改密码")
End If
Set view = userDB.GetView("($Users)")
If Not view Is Nothing Then
Call view.Refresh
End If
Set view = userDB.GetView("($ServerAccess)")
If Not view Is Nothing Then
Call view.Refresh
End If
'向控制台输入命令
Call session.SendConsoleCommand("",{sh nlcache reset})
Exit Sub
UnknowError:
Msgbox "修改密码错误行:" & Erl & "错误信息:" & Error
Exit Sub
End Sub