修改密码

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 
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值