首页 > 开发 > 综合 > 正文

修改工作组用户密码

2024-07-21 02:12:31
字体:
来源:转载
供稿:网友
下面是修改工作组用户密码的函数,调用时如果用于密码为空,请使用"",不要使用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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表