Note Password Change

  • Thread starter Thread starter Casey
  • Start date Start date
C

Casey

I use the code below to actually make the change of a
password, but I would like also to message the user if the
password actually has been changed. How would I determine
whether the verification of the password change was true
or false. I want to use that determination as in

If password change verification is true Then
MsgBox "Password has been successfully changed."
Else
MsgBox "Password has not been changed."
Endif

But, naturally using code instead of the "password
change verification" words that I use in the statement.

I would also place that If statement in the procedure
I have listed below.

I would appreciate any opinions.

Thank you,

Casey

Private Sub Command174E_Click()
If [NewPwd] = [Vrfy] Then
Dim ws As Workspace
Dim usr As User
Set ws = DBEngine.Workspaces(0)
With ws
Set usr = .Users(CurrentUser())
usr.NewPassword [OldPwd], [NewPwd]
End With
Else
DoCmd.OpenForm "Pwdmsgfrm3"
End If
End Sub
 
This code will tell you whether the user did or did not change his password:

dim s1 as string, s2 as string
s1=PW()
<let him change his password here>
s2=PW()
if strcomp (s1, s2, vbbinarycompare) = 0 then
msgbox "he did change it"
else
msgbox "he did not change it"
endif

Public Function PW() As String
Dim db As Database, rs As Recordset
Set db = DBEngine.OpenDatabase( _
SysCmd(acSysCmdGetWorkgroupFile))
Set rs = db.OpenRecordset( _
"select password from MSysAccounts" & _
" where name=""" & CurrentUser() & """")
PW = rs(0)
Set rs = Nothing
Set db = Nothing
End Function

The function returns the current user's user-level security password *in
encrypted form*. You can not reverse-engineer the user's actual password
from that encrypted value, so this code is *not* a break in security, and it
does *not* recover forgotten passwords! But it does let you see if his
password has changed.

HTH,
TC
 
Back
Top