Change Logon password (1 Viewer)

Kempes

Registered User.
Local time
Today, 05:02
Joined
Oct 7, 2004
Messages
327
Previously posted in General but got no response so decided to move to forms area.

I want to hide as many toolbar options/menus as I can on startup, so the user is very limited as to what they can do with the database.
I am using the multiuser logon option so each user has their own user name and password.
By hiding the menu, it also locks out the option to change their password.

I want to give users the ability to load the User and Group accounts/change logon screen only.

What I was thinking was calling this option from a command button on a form.
ie, Once clicked, it takes you to the generic Change Logon screen with the need for the menus to be enabled.

Can this be done?
If not, is there an alternative.

Thanks

Kempes
 

john471

Registered User.
Local time
Today, 14:02
Joined
Sep 10, 2004
Messages
392
Here's what I did...

Create a form with four unbound textboxes
1) Holds Current UserName - locked - this form will only be for the current user to reset their own password. (txtLogonID)
2) for user to enter their current pasword (txtPWCurrent)
3) for user to enter new password - asterisked out - used Input Mask = Password (txtPWNew)
4) for user to verify entry of password (because it is asterisked out) - also asterisked out - used Input Mask = Password (txtPWNewVerify)

The form's Form_Open procedure sets the value of txtLogonID
Code:
Me.txtLogonID.Value = DBEngine.Workspaces(0).UserName

and an OK and Cancel command buttons.

The OK button does some verification...
1) the new password and verify boxes must be exactly the same
2) new password must meet minimum and maximum length requirements

Then re-sets the pasword using....
Code:
DBEngine.Workspaces(0).Users(Me.txtLogonID.Value).NewPassword Nz(Me.txtPWCurrent), Me.txtPWNew

Look out for (and handle) especially the following errors..

3029 - Not a valid account name or password
3033 - Not a valid current password

HTH

Regards

John.
 

Kempes

Registered User.
Local time
Today, 05:02
Joined
Oct 7, 2004
Messages
327
Thanks.

I'll have a crack at that.

Also, is there a quick way to unhide the toolbars for admin only?
 

Kempes

Registered User.
Local time
Today, 05:02
Joined
Oct 7, 2004
Messages
327
Thanks, this works, but when verifying the password, it allows you to change it without verifying. When testing, I deliberatly spelt my new password wrong in the verify box and it allowed me to continue.

What have I done wrong?
 

Kempes

Registered User.
Local time
Today, 05:02
Joined
Oct 7, 2004
Messages
327
OK.

Got it to verify but how do you get it to check the length?

code so far

Private Sub Command5_Click()
On Error GoTo Command5ERR_click

If Me.txtPWNew <> Me.txtPWNewVerify Then
MsgBox "The verification password does not match your New Password, Please retype both", vbCritical + vbOKOnly, "PASSWORD MISMATCH"
Me.txtPWNew = Null
Me.txtPWNewVerify = Null
Me.txtPWNew.SetFocus
Else
DBEngine.Workspaces(0).Users(Me.txtlogonID.Value).NewPassword Nz(Me.txtPWCurrent), Me.txtPWNew
MsgBox "Password succesfully changed", vbInformation + vbOKOnly, "PASSWORD CHANGED"
DoCmd.close acForm, "ChangePassword"
End If

Command5Exit_Click:
Exit Sub

Command5ERR_click:
MsgBox "ERROR, Please retype the correct information or contact your system administrator to clear down your password", vbCritical + vbOKOnly, "ERROR"
Me.txtPWCurrent = Null
Me.txtPWNew = Null
Me.txtPWNewVerify = Null
Me.txtPWCurrent.setfocus
Resume Command5Exit_Click

End Sub

Private Sub Form_Open(Cancel As Integer)
Me.txtlogonID.Value = DBEngine.Workspaces(0).UserName
End Sub
 

john471

Registered User.
Local time
Today, 14:02
Joined
Sep 10, 2004
Messages
392
I use similar to below (with a couple of extra enhancements). I didn't want to just give you my code; I thought it better to give you the concept and let you write your own ;) ), but seeing as you've had a pretty good crack at it... I'll give you my cheat notes....

Code:
Option Compare Binary 'Very important - see below
Option Explicit

Const mConSzModName As String = "frmAdminMyPwd"
Dim mSzMsgTitle As String
Dim mSzMsgPrompt As String


Private Sub cmdOK_Click()
    On Error GoTo cmdOK_Click_err
    Const conszProcedureName As String = "cmdOK_Click"
    If Nz(Me.txtPWNew.Value) <> Nz(Me.txtPWNewVerify.Value) Then
        'Option Compare Binary - Case Sensitive
        MsgBox "The password you have entered failed verification." & vbCrLf & "Please ensure you type the same password into both the 'New Password' and the 'Verify New Password' fields." & vbCrLf & "Passwords are Case Sensitive.", vbOKOnly + vbExclamation, "Verification Failure"
        Me.txtPWNew.Value = vbNullString
        Me.txtPWNewVerify.Value = vbNullString
        Me.txtPWNew.SetFocus
    Else
        If Len(Nz(Me.txtPWNew.Value)) < 6 Or Len(Nz(Me.txtPWNew.Value)) > 14 Then
            MsgBox "Please choose a new password that is between 6 and 14 characters long.", vbOKOnly + vbExclamation, "Invalid Password Length"
            Me.txtPWNew.Value = vbNullString
            Me.txtPWNewVerify.Value = vbNullString
            Me.txtPWNew.SetFocus
        Else
            DBEngine.Workspaces(0).Users(Me.txtLogonID.Value).NewPassword Nz(Me.txtPWCurrent), Me.txtPWNew
            MsgBox "Your password has been changed.", vbOKOnly + vbInformation, "Success"
            'You may or may not want the line below
            DoCmd.Close acForm, Me.Name
        End If
    End If
    
cmdOK_Click_Exit:
    Exit Sub
    
cmdOK_Click_err:
    If Err.Number = 3029 Then
        mSzMsgTitle = "Not a valid account name or password"
        mSzMsgPrompt = "You entered an invalid account (user) name or password."
        Me.txtPWCurrent.SetFocus
    ElseIf Err.Number = 3033 Then
        mSzMsgTitle = "Not a valid current password"
        mSzMsgPrompt = "The password you have entered as the current password is incorrect."
        Me.txtPWCurrent.SetFocus
    Else
        'my general error handling layout....
        'using the constants allows me to copy and paste between modules,  and procedures, but also makes sure that I put the correct value in each time I do so (otherwise compile error).  This also relies on "Option Explicit" - which I always use.
        mSzMsgTitle = "Error"
        mSzMsgPrompt = "An unexpected error has occurred." _
        & vbCrLf & "Please record the circumstances of the error, and the EXACT details below, and report this error to your manager." _
        & vbCrLf & vbCrLf & mConSzModName & "!" & conszProcedureName _
        & vbCrLf & vbCrLf & "Error number : " & Err.Number _
        & vbCrLf & "Error Description : " & Err.Description _
        & vbCrLf & "Error Source : " & Err.Source
    End If
    MsgBox mSzMsgPrompt, vbExclamation + vbOKOnly, mSzMsgTitle
    Resume cmdOK_Click_Exit
    Resume Next  'this is here just for use in setting next statement during debug

End Sub


Private Sub Form_Open(Cancel As Integer)
    Me.txtLogonID.Value = DBEngine.Workspaces(0).UserName
End Sub
 

Users who are viewing this thread

Top Bottom