Password complexity rules with a custom logon form

G

Guest

Does anyone have any ideas on how to enact a password complexity rule system
in a custom logon form? I want to 1) restrict users to only use alphanumeric
passwords and 2) require at lest one letter and one number. I don't want to
use a ton of code or a 3rd party assembly to accomplish this. Any ideas
welcome.

Thank you,
Lionel
 
G

Guest

Hi

I would spin through the password string picking out each character
one-by-one and testing to make sure that they are alphnumeric by examining
their ASCII codes:

Use the Asc() function to return the ASCII code then test that number against:
48 to 57 are numeric (0-9)
65 to 90 are alpha (A to Z)
97 to 122 are also alpha (a to z)

Something like:

flgAlpha = False
flgNumeric = False
For n = 1 to Len(strngPW)
Select Case Asc(Mid(strngPW, n, 1)
Case < 48, 58 to 64, 91 to 96, > 122
Msgbox "Not a valid password"
Exit Sub
Case 48 to 57
flgNumeric = True
Case Else
flgAlpha = True
End Select
Next n
If Not flgAlpha Or Not flgNumeric then
MsgBox "Not a valid Password"
Exit Sub
End If
.... on-going coding goes here...


Cheers.

BW
 
G

Guest

Sorry - just spotted an error

The Select Case line should have another ')' on the end:
Select Case Asc(Mid(strngPW, n, 1))

Cheers.

BW
 
J

John Spencer

If Ucase(Password) LIKE "*[!0-9,A-Z]*" = True then
MsgBox "The password contains characters other than 0 to 9 or A to z"
End if

If Ucase(Password) LIKE "*[0-9]"
and Ucase(Password) Like "*[A-Z]*"
AND Ucase(Password) LIKE "*[!0-9,A-Z]*" = False Then

MsgBox "The password contains at least one number and one letter"

End IF

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 
J

John Spencer

Missed a wildcard


If Ucase(Password) LIKE "*[0-9]*"
and Ucase(Password) Like "*[A-Z]*"
AND Ucase(Password) LIKE "*[!0-9,A-Z]*" = False Then

MsgBox "The password contains at least one number and one letter"

End IF


'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================


John said:
If Ucase(Password) LIKE "*[!0-9,A-Z]*" = True then
MsgBox "The password contains characters other than 0 to 9 or A to z"
End if

If Ucase(Password) LIKE "*[0-9]"
and Ucase(Password) Like "*[A-Z]*"
AND Ucase(Password) LIKE "*[!0-9,A-Z]*" = False Then

MsgBox "The password contains at least one number and one letter"

End IF

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================

Does anyone have any ideas on how to enact a password complexity rule
system in a custom logon form? I want to 1) restrict users to only
use alphanumeric passwords and 2) require at lest one letter and one
number. I don't want to use a ton of code or a 3rd party assembly to
accomplish this. Any ideas welcome.

Thank you,
Lionel
 
G

Guest

Thanks John! That code works great and is slim.
-Lionel

John Spencer said:
Missed a wildcard


If Ucase(Password) LIKE "*[0-9]*"
and Ucase(Password) Like "*[A-Z]*"
AND Ucase(Password) LIKE "*[!0-9,A-Z]*" = False Then

MsgBox "The password contains at least one number and one letter"

End IF


'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================


John said:
If Ucase(Password) LIKE "*[!0-9,A-Z]*" = True then
MsgBox "The password contains characters other than 0 to 9 or A to z"
End if

If Ucase(Password) LIKE "*[0-9]"
and Ucase(Password) Like "*[A-Z]*"
AND Ucase(Password) LIKE "*[!0-9,A-Z]*" = False Then

MsgBox "The password contains at least one number and one letter"

End IF

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================

Does anyone have any ideas on how to enact a password complexity rule
system in a custom logon form? I want to 1) restrict users to only
use alphanumeric passwords and 2) require at lest one letter and one
number. I don't want to use a ton of code or a 3rd party assembly to
accomplish this. Any ideas welcome.

Thank you,
Lionel
 

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