Solved

Reset user's password VBA

Posted on 2009-05-14
10
573 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 125 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

623 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