Password Expiry

G

Guest

I have a couple of forms protected by passwords. Is it possible to add an
expiry so that the passwords have to be changed after say every 30 days? I'm
guessing that this would need to be linked to another form where this
password is changed?
 
R

Rob Oldfield

Presumably at the moment you have a table listing usernames and passwords
and are doing some kind of lookup on that. Just add another date field
containing when the password was set (or expires) and include a lookup on
that as well. Then yes, if it's getting close to expiry, display a password
change form.

<standard disclaimer>
You realise that those passwords don't actually provide *any* real security?
</standard disclaimer>
 
G

Guest

Nope it is a standalone database on one computer but with multiple users
throughout the day.

The password is set to two of the buttons on the form with the following code

Function GetPwd() As Boolean

Dim strpwd As String
Const conGoodPwd As String = "Winter05"
Dim intMaxTries As Integer

For intMaxTries = 1 To 3
strpwd = InputBox("Enter Password")
If strpwd = "" Then
GetPwd = False
Exit For
End If
If strpwd = conGoodPwd Then
GetPwd = True
Exit For
End If
If MsgBox("Incorrect Password", vbExclamation + vbOKCancel, "Error") =
vbCancel Then
GetPwd = False
Exit For
End If
Next intMaxTries

End Function

Private Sub Command35_Click()
On Error GoTo Err_Command35_Click

Dim stDocName As String

stDocName = "mcrReports"
If GetPwd() Then
DoCmd.RunMacro stDocName
End If

Exit_Command35_Click:
Exit Sub

Err_Command35_Click:
MsgBox Err.Description
Resume Exit_Command35_Click

End Sub
 
R

Rob Oldfield

Well there's no way in the world (...not strictly true, but it'd be a lot of
work) that it's going to be updateable if it's hard coded in the code behind
a button.

Add another table (called Password maybe) just with two fields Password
(text) and ExpiryDate (date). Add a single record with a password and when
you want it to expire. Replace

If strpwd = conGoodPwd Then
GetPwd = True
Exit For
End If

with (aircode)...

dim d as date, resp as integer, newpwd as string
getpwd=false
if strpwd=dlookup("[Password]","Password") then
d=dlookup("[ExpiryDate]","Password")
if date()<=d then
if datediff("d",date(),d)<3 then
resp=msgbox("Going to expire. Change it?", _
vbyesno,"Update pwd")
if resp=vbyes then
newpwd=inputbox("Change to?")
'use dateadd to add however many days onto d, then
'run an update query to overwrite expirtydate with the new
'date and password to newpwd
endif
endif
getpwd=true
exit for
endif
endif

(note, by the way, that indenting Ifs and loops makes it a damn sight easier
to read.)

And it's still pointless. What will happen in real life will be that the
person who changes it will probably write the new password down on a post-it
note stuck to the screen. If they don't then they've just locked everybody
else out. Those that don't know about the shift key anyway.
 
G

Guest

Unfortunately mine is not to question why on this one, I've been told to add
a password change button and a password change is what I must have. Even
though it's completely pointless

Oh what wonders the shift key is. I was showing the database to an 'IT'
collegue in Germany who is going to be based where it is to be used. When I
opened it with the shift key it was like I'd made his whole year

Rob Oldfield said:
Well there's no way in the world (...not strictly true, but it'd be a lot of
work) that it's going to be updateable if it's hard coded in the code behind
a button.

Add another table (called Password maybe) just with two fields Password
(text) and ExpiryDate (date). Add a single record with a password and when
you want it to expire. Replace

If strpwd = conGoodPwd Then
GetPwd = True
Exit For
End If

with (aircode)...

dim d as date, resp as integer, newpwd as string
getpwd=false
if strpwd=dlookup("[Password]","Password") then
d=dlookup("[ExpiryDate]","Password")
if date()<=d then
if datediff("d",date(),d)<3 then
resp=msgbox("Going to expire. Change it?", _
vbyesno,"Update pwd")
if resp=vbyes then
newpwd=inputbox("Change to?")
'use dateadd to add however many days onto d, then
'run an update query to overwrite expirtydate with the new
'date and password to newpwd
endif
endif
getpwd=true
exit for
endif
endif

(note, by the way, that indenting Ifs and loops makes it a damn sight easier
to read.)

And it's still pointless. What will happen in real life will be that the
person who changes it will probably write the new password down on a post-it
note stuck to the screen. If they don't then they've just locked everybody
else out. Those that don't know about the shift key anyway.


Welly said:
Nope it is a standalone database on one computer but with multiple users
throughout the day.

The password is set to two of the buttons on the form with the following code

Function GetPwd() As Boolean

Dim strpwd As String
Const conGoodPwd As String = "Winter05"
Dim intMaxTries As Integer

For intMaxTries = 1 To 3
strpwd = InputBox("Enter Password")
If strpwd = "" Then
GetPwd = False
Exit For
End If
If strpwd = conGoodPwd Then
GetPwd = True
Exit For
End If
If MsgBox("Incorrect Password", vbExclamation + vbOKCancel, "Error") =
vbCancel Then
GetPwd = False
Exit For
End If
Next intMaxTries

End Function

Private Sub Command35_Click()
On Error GoTo Err_Command35_Click

Dim stDocName As String

stDocName = "mcrReports"
If GetPwd() Then
DoCmd.RunMacro stDocName
End If

Exit_Command35_Click:
Exit Sub

Err_Command35_Click:
MsgBox Err.Description
Resume Exit_Command35_Click

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top