Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Reset user's password VBA

Posted on 2009-05-14
10
Medium Priority
?
579 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 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

688 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