修改工作组用户密码

时间:2009-07-11 01:45:04   来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:lean 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", "")    '//要特别注意上面一句,必须使用拥有数据库管理权限的用户名和密码打开...
  正文:

下面是修改工作组用户密码的函数,调用时如果用于密码为空,请使用"",不要使用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



来源:http://www.002pc.com/master/College/Database/Access/2009-07-11/10028.html

收藏到:

关于《修改工作组用户密码》文章的评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面

随机文章

    SQL Error: select * from ***_ecms_article where classid='98' and checked=1 order by rand() limit 10

顶出来的热门

    SQL Error: select * from ***_ecms_article where classid='98' and checked=1 order by diggtop desc,id desc limit 10
站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td