Changing a password - via VBA

Leif

Registered User.
Local time
Today, 02:24
Joined
Jan 20, 2011
Messages
79
I'm trying to find some way to change the password of a user given I don't know their password, in code. So it is something like running "User and Group Accounts", then selecting a user, then clicking the clear button, then setting a new password.

I've tried using ALTER USER command, but it requires an old password. I also tried using a routine from SECFAQ.doc, called faqChangePassword. "In Theory" it is suppose to allow you to change a user's password if the person running the routine has "Admins" rights. I do belong to the "Admins" group, however, I get an error 3033, "You do not have permissions to use the <user name> object. Have your system administrator or the person who created this object establish the appropriate permissions for you."

The routine I'm using is:

Function faqChangePassword (ByVal strUser As String, _
ByVal strPwd As String) As Integer

Dim ws As Workspace
Dim usr As User

Set ws = DBEngine.Workspaces(0)
Set usr = ws.Users(strUser)
usr.NewPassword "", strPwd
End Function

It works if I don't have a password, but if I already have a password it does not work.

Regards,
Leif
 
Yes, I did.

It is the same routine I published before, faqChangePassword. I noted in the original post that it did not work. Now it works. However, I don't recall what I did to avoid the error. Perhaps I thought I was in the Admins group, but wasn't.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom