Function CheckUserPassWordInGroup(UserName As String,_
oldPassword As String, newPassWord As String) As Boolean
On Error GoTo ChkErr
Dim wk As DAO.Workspace, Ur As DAO.User, i As Integer, Found As Boolean
CheckUserPassWordInGroup = False
Found = False
Set wk = DBEngine.CreateWorkspace("", "Admin", "")
'//要特別注意上面一句,必須使用擁有數據庫管理權限的用戶名和密碼打開工作區!
'//下面一段是查找用戶名是否存在,如果存在,修改密碼,不存在出錯報告。
For i = 0 To wk.Users.Count - 1
If wk.Users(i).Name = UserName Then
Set Ur = wk.Users(i)
Found = True
Ur.newPassword oldPassword, newPassWord
Exit For
End If
Next i
If Not Found Then
MsgBox "'" & UserName & "' 不是一個有效的用戶名!",_
vbExclamation, "艾賽思應用網"
CheckUserPassWordInGroup = False
Exit Function
End If
CheckUserPassWordInGroup = True
Exit Function
ChkErr:
MsgBox "'" & UserName & "' 用戶密碼修改失敗!",_
vbExclamation, "艾賽思應用網"
CheckUserPassWordInGroup = False
End Function