Correct. This sample validates a string against a set of predefined requirements. Any problem with that?..
-- Al > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:ActiveDir- > [EMAIL PROTECTED] On Behalf Of Al Mulnick > Sent: Saturday, December 17, 2005 7:00 PM > To: [email protected] > Subject: Re: [ActiveDir] password changer > > Al, just so I understand you're not querying for the password complexity > in this script, but rather just making the script check what you already > know the password complexity to be. Correct? > > Al > > On 12/17/05, Alexander Suhovey <[EMAIL PROTECTED]> wrote: > > > If anyone knows how to query a password against complexity > requirements, > > > I'd like to know how. > > > > When it comes to string validation the answer is almost always "Regular > > Expressions". The vbscript example below tests arbitrary string for > > compliance with "Password must meet security requirements" policy in > > Windows. (watch for line wraps) > > > > ==8<=============== > > > > Option Explicit > > Dim arrReq1(0),arrReq2(3),iReq,sErr,sArg,iNum,i > > > > 'Mandatory Requirement > > '===================== > > arrReq1(0) = ".{8,128}" ' length is 8 to 128 chars > > > > 'Group Requirements > > '================== > > iReq = 3 ' Must meet this number > > ' of requirements below > > arrReq2(0) = "(?=.*[a-z])" ' contains lower letter > > arrReq2(1) = "(?=.*[A-Z])" ' contains upper letter > > arrReq2(2) = "(?=.*\d)" ' contains digit > > arrReq2(3) = "(?=.*[^a-zA-Z\d])" ' contains non-alphanumeric > > > > sErr = "Password does not meet security requirements" > > iNum = 0 > > > > 'String being tested against req's > > '================================= > > 'sArg = "passwor" > > 'sArg = "password" > > 'sArg = "Password" > > 'sArg = "P4ssword" > > sArg = "P4s$word" > > > > If not ArgVrf(sArg,arrReq1(0)) Then > > WScript.Echo sErr > > WScript.Quit 1 > > End If > > For i = LBound(arrReq2) to UBound(arrReq2) > > If ArgVrf(sArg,arrReq2(i)) Then iNum = iNum+1 > > Next > > If iNum<iReq Then > > WScript.Echo sErr > > WScript.Quit 1 > > End If > > WScript.Echo "Test passed" > > > > Function ArgVrf(arg,pattern) > > Dim objRegExp > > Set objRegExp = New RegExp > > objRegExp.IgnoreCase = false > > objRegExp.Pattern = pattern > > ArgVrf = objRegExp.Test(arg) > > Set objRegExp = Nothing > > End Function > > > > ==8<=============== > > > > > > -- > > Al > > > > > > > > > > > > > > List info : http://www.activedir.org/List.aspx > > List FAQ : http://www.activedir.org/ListFAQ.aspx > > List archive: http://www.mail- > archive.com/activedir%40mail.activedir.org/ > > > List info : http://www.activedir.org/List.aspx List FAQ : http://www.activedir.org/ListFAQ.aspx List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/
