complex password validation

x18access

Registered User.
Local time
Yesterday, 22:44
Joined
Jan 5, 2014
Messages
14
Hi

i am looking to ensure the user enters a complex password, in the add user form.
Therefore, the password should be >8 characters, 2 numbers, 1 Ucase min, 1 Lcase min and some form of punctuation.
I found this code:

unction ValidatePassword(ByVal pwd As String,
Optional ByVal minLength As Integer = 8,
Optional ByVal numUpper As Integer = 2,
Optional ByVal numLower As Integer = 2,
Optional ByVal numNumbers As Integer = 2,
Optional ByVal numSpecial As Integer = 2) As Boolean

' Replace [A-Z] with \p{Lu}, to allow for Unicode uppercase letters.
Dim upper As New System.Text.RegularExpressions.Regex("[A-Z]")
Dim lower As New System.Text.RegularExpressions.Regex("[a-z]")
Dim number As New System.Text.RegularExpressions.Regex("[0-9]")
' Special is "none of the above".
Dim special As New System.Text.RegularExpressions.Regex("[^a-zA-Z0-9]")

' Check the length.
If Len(pwd) < minLength Then Return False
' Check for minimum number of occurrences.
If upper.Matches(pwd).Count < numUpper Then Return False
If lower.Matches(pwd).Count < numLower Then Return False
If number.Matches(pwd).Count < numNumbers Then Return False
If special.Matches(pwd).Count < numSpecial Then Return False

' Passed all checks.
Return True
End Function

Sub TestValidatePassword()
Dim password As String = "Password"
' Demonstrate that "Password" is not complex.
MsgBox(password & " is complex: " & ValidatePassword(password))

password = "Z9f%a>2kQ"
' Demonstrate that "Z9f%a>2kQ" is not complex.
MsgBox(password & " is complex: " & ValidatePassword(password))
End Sub

but obviously this doesn't work in access.
How can i either change it to work for microsoft access, or how would i go about developing it. What would the code be?
Apologies for being such a noob.

Regards.
 
Looks like VBA to me, but is referring to a library reference for the System object.

I would go back to where you got the code from and see if it mentions the need to add a library or reference - or perhaps it is coming from a class module - either way I don't think you have all the code or references that relate to this code
 
I would think very carefully about imposing strict password constraints on users of an application like Access. If you need protection against brute-force password crackers, then perhaps Access is not the right application for your purposes.

If you wish to impose these pwd restrictions just because it is fashonable, then don't - the users will curse this forever.
 
password_strength.png
 
love it! Shame I have to add some text to get over 10 chars for this post
 

Users who are viewing this thread

Back
Top Bottom