设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

修改工作组用户密码

1970-1-1 08:00| 发布者: 笨小漆| 查看: 1852| 评论: 0

下面是修改工作组用户密码的函数,调用时如果用于密码为空,请使用"",不要使用null,两者不同。:)

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

最新评论

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2025-4-4 05:17 , Processed in 0.066219 second(s), 17 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部