Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password Complexity Script some part of script getting ignored

Status
Not open for further replies.

NinjaDog

Systems Engineer
May 25, 2021
1
SG
Hi guys. I have edited below vbscript from Microsoft MDT to include a password complexity check function. However, it seems to be ignoring the part where it checks the password for alphabets and special characters. Can anyone tell me where I've gone wrong? Thanks!

Code:
' // ***************************************************************************
' // 
' // Copyright (c) Microsoft Corporation.  All rights reserved.
' // 
' // Microsoft Deployment Toolkit Solution Accelerator
' //
' // File:      DeployWiz_Validation.vbs
' // 
' // Version:   6.3.8456.1000
' // 
' // Purpose:   Main Client Deployment Wizard Validation routines
' // 
' // ***************************************************************************

Option Explicit


'''''''''''''''''''''''''''''''''''''
'  Validate Password
'

Dim Upper,Lower,Number,Special,UpperFound,LowerFound,NumberFound,SpecialFound,PasswordBad

Upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Lower = "abcdefghijklmnopqrstuvwxyz"
Number = "0123456789"
Special = "~!@#$%^&*_-+=`|\(){}[]:;""'<>,.?/"
UpperFound = "NO"
LowerFound = "NO"
NumberFound = "NO"
SpecialFound = "NO"


Function ValidatePassword
	
	ValidatePassword = ParseAllWarningLabels
	
	
	NonMatchPassword.style.display = "none"
	If Password1.Value <> "" then
		If Password1.Value <> Password2.Value then
			ValidatePassword = FALSE
			NonMatchPassword.style.display = "inline"
		End if
	End if
	
	If len(Password1.Value) < 12 then
		ValidatePassword = FALSE
	End if
	
	Dim i,char
	for i = 1 to len(Password1.value)
		char = mid(Password1.value,i,1)
		if instr(Upper, char) then
			UpperFound = "YES"
		elseif instr(Lower, char) then
			LowerFound = "YES"
		elseif instr(Number, char) then
			NumberFound = "YES"
		elseif instr(Special, char) then
			SpecialFound = "YES"
		end if
	Next
	
	NonComplexPassword.style.display ="none"
	If UpperFound = "NO" then
		ValidatePassword = FALSE
			NonComplexPassword.style.display ="inline"
	ElseIf LowerFound = "NO" then
		ValidatePassword = FALSE
			NonComplexPassword.style.display ="inline"
	ElseIf NumberFound = "NO" then
		ValidatePassword = FALSE
			NonComplexPassword.style.display ="inline"
	ElseIf SpecialFound = "NO" then
		ValidatePassword = FALSE
			NonComplexPassword.style.display ="inline"
	end if
	
	
	ButtonNext.Disabled = not ValidatePassword	


End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top