How do I ask users to change their password on a monthly basis (1 Viewer)

cursedeye

Registered User.
Local time
Today, 03:10
Joined
Oct 7, 2009
Messages
50
I've setup some users for my database using Tool> User-Level Security Wizard.
I'm wondering how do I ask users to change their passwords every month.

Thanks
 

ajetrumpet

Banned
Local time
Today, 01:10
Joined
Jun 22, 2007
Messages
5,638
store the password change in a table along with the system date. then, every month thereafter, ask.
 

cursedeye

Registered User.
Local time
Today, 03:10
Joined
Oct 7, 2009
Messages
50
How do i do that?

How do I store password?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 07:10
Joined
Sep 12, 2006
Messages
15,749
first, how do the users change their passwords?

because presumably, the users are not admins, and cant run the security wizard themselves

so do you mean (or also mean)- how do i enable a user to change his password?
 

cursedeye

Registered User.
Local time
Today, 03:10
Joined
Oct 7, 2009
Messages
50
I have the same question.

With the current setting which was done by using the User-Level Security Wizard,I have to login as Admin and manually clear users password.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 07:10
Joined
Sep 12, 2006
Messages
15,749
i cant find the thread, but i posted code to enable a user to change his password programmatically only the other day

search for password, and you should find it
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 07:10
Joined
Sep 12, 2006
Messages
15,749
you have to save the date they last changed the pwd

then in the first code you run when you open the app, you need to test the date, and make them change it again whenever is appropriate

part of this THEN possibly means that you need to lock the dbs down to prevent them modifying either the code, or changing the date they changed the password.
 

cursedeye

Registered User.
Local time
Today, 03:10
Joined
Oct 7, 2009
Messages
50
you have to save the date they last changed the pwd

then in the first code you run when you open the app, you need to test the date, and make them change it again whenever is appropriate

part of this THEN possibly means that you need to lock the dbs down to prevent them modifying either the code, or changing the date they changed the password.

I'm not sure how I can do it.

Here is the code that I'm using
Option Compare Database
Option Explicit

Const adhcErrNameNotInCollection = 3265
Const adhcErrAccntAlreadyExists = 3390
Const adhcErrBadPid = 3304
Const adhcErrCantPerformOperation = 3032
Const adhcErrNoPermission = 3033
Const adhcErrBadAccntName = 3030
Const adhcErrBadAccntOrPwd = 3029
Const adhcErrCantPerformAccntOperation = 3109

Function adhcboUsersFill(ctl As Control, varID As Variant, varRow As Variant, varCol As Variant, varCode As Variant) As Variant

Static swrk As Workspace
Static sastrUsr() As String
Static sintUsrCnt As Integer
Dim usr As User
Dim varReturn As Variant
Dim strName As String

Set swrk = DBEngine.Workspaces(0)
Select Case varCode
Case acLBInitialize
sintUsrCnt = 0
swrk.Users.Refresh
ReDim sastrUsr(1 To swrk.Users.count)
For Each usr In swrk.Users
strName = usr.Name
If strName <> "Engine" And strName <> "Creator" And strName <> "Admin" Then
sintUsrCnt = sintUsrCnt + 1
sastrUsr(sintUsrCnt) = strName
End If
Next usr
ReDim Preserve sastrUsr(1 To sintUsrCnt)
varReturn = True
Case acLBOpen
varReturn = Timer
Case acLBGetRowCount
varReturn = sintUsrCnt
Case acLBGetValue
varReturn = sastrUsr(varRow + 1)
End Select

adhcboUsersFill = varReturn

End Function

Private Sub cboUsers_AfterUpdate()

' Disable txtOldPwd if an Admins
' member is changing the password of
' another user since it's unneeded.
If cboUsers = CurrentUser() Then
Me!txtOldPwd.Enabled = True
Else
Me!txtOldPwd.Enabled = False
End If

End Sub

Private Sub cmdClose_Click()
DoCmd.Close
End Sub

Private Sub cmdPwd_Click()

Dim fok As Boolean
Dim ctlOldPwd As TextBox
Dim ctlNewPwd As TextBox
Dim ctlConfirmNewPwd As TextBox
Dim strMsg As String

Set ctlOldPwd = Me!txtOldPwd
Set ctlNewPwd = Me!txtNewPwd
Set ctlConfirmNewPwd = Me!txtConfirmNewPwd

' Perform a binary string comparison of the password
' and the confirmation password.
If StrComp(Nz(ctlNewPwd), Nz(ctlConfirmNewPwd), vbBinaryCompare) = 0 Then
fok = adhSetPwd(strUser:=cboUsers, strOldPwd:=Nz(ctlOldPwd), strNewPwd:=Nz(ctlNewPwd))
If fok Then
strMsg = "Password changed!"
ctlOldPwd = ""
ctlNewPwd = ""
ctlConfirmNewPwd = ""
Else
strMsg = "Password change failed!"
End If
Else
strMsg = "New password entry does not match confirming password entry!"
End If

MsgBox strMsg, vbOKOnly + vbInformation, "Change Password"

End Sub

Private Sub Form_Load()

' If not a member of Admins lock
' and disable the user combo box.
With Me!cboUsers
If Not adhIsGroupMember("Admins") Then
.Locked = True
.Enabled = False
.BackColor = 12632256
Else
.Locked = False
.Enabled = True
.BackColor = 16777215
End If
End With
End Sub
Private Function adhSetPwd(ByVal strUser As String, ByVal strOldPwd As String, ByVal strNewPwd As String) As Boolean

' Sets a new password for user account.
' You must be a member of Admins to set password
' of another user.
'
' In:
' strUser: name of user account
' strOldPwd: existing password; ignored if you
' are a member of Admins and are setting
' password of account other than your own;
' use "" if there is no existing password
' strNewPwd: new password;
' use "" to remove the password
' Out:
' Return Value: True if succeeded; False if failed
' Example:
' fOK = adhSetPwd("Kizzie", "", "Red")

On Error GoTo adhSetPwdErr

Dim wrk As Workspace
Dim usr As User
Dim strMsg As String

Const adhcProcName = "adhSetPwd"

adhSetPwd = False

Set wrk = DBEngine.Workspaces(0)

'Point to user object
Set usr = wrk.Users(strUser)

'Only Admins members can change other users' passwords
'For Admins members, old pwd is ignored
usr.NewPassword strOldPwd, strNewPwd


adhSetPwd = True

adhSetPwdDone:
On Error GoTo 0
Exit Function

adhSetPwdErr:
Select Case Err
Case adhcErrNameNotInCollection
strMsg = "The user account '" & strUser & "' doesn't exist."
Case adhcErrNoPermission
strMsg = "You don't have permission to perform this operation or you have entered the wrong old password."
Case Else
strMsg = "Error " & Err.Number & ": " & Err.Description
End Select
MsgBox strMsg, vbCritical + vbOKOnly, "Password Error!"
Resume adhSetPwdDone

End Function

Private Function adhIsGroupMember(ByVal strGroup As String, Optional ByVal varUser As Variant) As Boolean

' Verifies if a user is a member of a group.
'
' From Access 97 Developer's Handbook
' by Litwin, Getz, and Gilbert. (Sybex)
' Copyright 1997. All Rights Reserved.
'
' In:
' strGroup: name of group
' strUser: optional name of user;
' if missing, current user is used
' Out:
' Return Value: True if user is member; False if not
' Example:
' fOK = adhIsGroupMember("Pets", "Kizzie")

On Error GoTo adhIsGroupMemberErr

Dim wrk As Workspace
Dim usr As User
Dim grp As Group
Dim strMsg As String
Dim intErrHndlrFlag As Integer
Dim varGroupName As Variant

Const adhcFlagSetUser = 1
Const adhcFlagSetGroup = 2
Const adhcFlagCheckMember = 4
Const adhcFlagElse = 0

Const adhcProcName = "adhIsGroupMember"

adhIsGroupMember = False

'Initialize flag for determining
'context for error handler
intErrHndlrFlag = adhcFlagElse

Set wrk = DBEngine.Workspaces(0)

'Refresh users and groups collections
wrk.Users.Refresh
wrk.Groups.Refresh

If IsMissing(varUser) Then varUser = CurrentUser()

intErrHndlrFlag = adhcFlagSetUser
Set usr = wrk.Users(varUser)

intErrHndlrFlag = adhcFlagSetGroup
Set grp = wrk.Groups(strGroup)

intErrHndlrFlag = adhcFlagCheckMember
varGroupName = usr.Groups(strGroup).Name

If Not IsEmpty(varGroupName) Then
adhIsGroupMember = True
End If

adhIsGroupMemberDone:
On Error GoTo 0
Exit Function

adhIsGroupMemberErr:
Select Case Err
Case adhcErrNameNotInCollection
Select Case intErrHndlrFlag
Case adhcFlagSetUser
strMsg = "The user account '" & varUser & "' doesn't exist."
Case adhcFlagSetGroup
strMsg = "The group account '" & strGroup & "' doesn't exist."
Case adhcFlagCheckMember
Resume Next
Case Else
strMsg = "Error " & Err.Number & ": " & Err.Description
End Select
Case adhcErrNoPermission
strMsg = "You don't have permission to perform " & "this operation."
Case Else
strMsg = "Error " & Err.Number & ": " & Err.Description
End Select
MsgBox strMsg, vbCritical + vbOKOnly, "Procedure " & adhcProcName
Resume adhIsGroupMemberDone

End Function

Thanks
 

Users who are viewing this thread

Top Bottom