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 
新闻热点
疑难解答