Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Reset user's password VBA

Posted on 2009-05-14
10
Medium Priority
?
584 Views
Last Modified: 2012-05-07
How can I reset a user's password using VBA. I want my admins to be able to do this through a button click on a form.

I considered:
DBEngine.Workspaces(0).Users(username).NewPassword

But for that to work you need to have the user's old password and you can't just use
DBEngine.Workspaces(0).Users(username).Password
to get it.
0
Comment
Question by:bejhan
  • 4
  • 3
  • 3
10 Comments
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 24387664
<<DBEngine.Workspaces(0).Users(username).NewPassword>>
  You don't need to have the old password, but you do need to be a member of the admins group.
JimD.
0
 
LVL 75
ID: 24387674
Basically this:

Public Function SSF_PwdCtl() As Boolean
   

' all code from experts exchange
    'Dim WS As DAO.Workspace
    Dim sDbName As String
    Dim sPwdOld As String
    Dim sPwdNew As String
    Dim db As DAO.Database

    sDbName = "C:\SomeApp.mdb"
    sPwdOld = InputBox("Old Pwd: ")
    sPwdNew = InputBox("New Pwd:")

   
    Set db = DBEngine.Workspaces(0).OpenDatabase(sDbName, options:=True, readonly:=False, Connect:=";PWD=" & sPwdOld & ";")
   
    db.NewPassword sPwdOld, sPwdNew
   
    MsgBox "Pwd Accepted"
    Set db = Nothing
    SSF_PwdCtl = True

End Function

mx
0
 
LVL 75
ID: 24387680
I assume you are referring to the database password ?

mx
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 58
ID: 24387688
FYI, you don't need the old password and I should have been clearer; when your part of the admins group, you can pass an empty string for either the old or new password argument.
JimD.
0
 
LVL 1

Author Comment

by:bejhan
ID: 24389852
JDettman that's perfect thanks.

Also I was wondering if there is a way to detect if a user's password is blank?
0
 
LVL 75
ID: 24389904
Seems in the code I posted ... if I didn't supply the old password, it did not work.  And ... you certainly have to do that if you are doing it manually ... and I would hope so, otherwise anyone could change the password.  Again, I'm talking about the database password, not ULS.

Are you ?

mx
0
 
LVL 1

Author Comment

by:bejhan
ID: 24389917
Oh sorry MX forgot to reply to you, I was referring to ULS.
0
 
LVL 75
ID: 24389924
ok ... then ignore what I said.

mx
0
 
LVL 58
ID: 24394744
<<Also I was wondering if there is a way to detect if a user's password is blank?>>
  Only way I can think of doing that is to attempt to open a workspace object for that user with a blank password and see if it errors or not.
JimD.
0
 
LVL 1

Author Comment

by:bejhan
ID: 24398553
Ah, I never even thought of that. Works perfect. Previous to this I was making an entry in my user log about setting a password and having to remove it when the password was reset. Not a solution I was happy with.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question