Hello,
I am trying to pull the bad password time and count values from AD using VBScript. These values are not
syncronized, so to get an accurate value I have to pull it from each DC (we have 8) and compare them. To
do that I am using the URL LDAP format to bind to the copy of AD on each specific system. I am having
trouble pulling the value, I get the error of "Object does not support this method". This is confusing becouse I can pull the badPwdCount value easily. The only difference
that I can see is that badPwdCount is stored as an Integer and badPasswordTime is an Integer8, a 64 bit value. Everything else is the same, the path, etc. Could
this be my problem, if so how do I fix it? Thanks!
Option Explicit
'On Error Resume Next
dim user
dim userName
dim badLogin
dim dom
dim OU
dim usr
dim concat
dim binder
dim secondConcat
dim tempHolder
dim domain
dim obj
dim secondObj
dim thing
dim thingTwo
dim dcArray(40) 'For Holding DC Names
dim counter
dim secondCounter
dim ReplacedString
dim RegularExpressionObject
if wscript.arguments.count <>2 then
wscript.echo "Syntax error. Usage: cscript lastfail.vbs username domain"
wscript.quit (5555)
end if
Set RegularExpressionObject=New RegExp
With RegularExpressionObject
.Pattern="CN="
.IgnoreCase=False
.Global=False
End With
userName = wscript.arguments(0)
domain = wscript.arguments(1)
Function FindNBind() 'Shamelessly stolen from Jeffrey Honneyman
dim myObj
set myObj=GetObject("LDAP://rootDSE"
FindNBind=myObj.get("defaultNamingContext"
end Function
FindNBind 'Calling the function
dom = FindNBind
concat="LDAP://OU=Domain Controllers,"& dom
set obj=GetObject(concat) 'binding to DC's Object
for each thing in obj
counter=0
tempHolder=thing.name
ReplacedString = RegularExpressionObject.Replace (tempHolder,""
dcArray(counter)=ReplacedString & "." & domain
secondConcat="LDAP://" & dcArray(counter) & "/CN=" & userName & "," & "CN=Users," & dom
set secondObj=GetObject(secondConcat)
badLogin = secondObj.get("badPasswordTime" 'this is where I get the error.
wscript.echo badLogin
counter=counter+1
next
I am trying to pull the bad password time and count values from AD using VBScript. These values are not
syncronized, so to get an accurate value I have to pull it from each DC (we have 8) and compare them. To
do that I am using the URL LDAP format to bind to the copy of AD on each specific system. I am having
trouble pulling the value, I get the error of "Object does not support this method". This is confusing becouse I can pull the badPwdCount value easily. The only difference
that I can see is that badPwdCount is stored as an Integer and badPasswordTime is an Integer8, a 64 bit value. Everything else is the same, the path, etc. Could
this be my problem, if so how do I fix it? Thanks!
Option Explicit
'On Error Resume Next
dim user
dim userName
dim badLogin
dim dom
dim OU
dim usr
dim concat
dim binder
dim secondConcat
dim tempHolder
dim domain
dim obj
dim secondObj
dim thing
dim thingTwo
dim dcArray(40) 'For Holding DC Names
dim counter
dim secondCounter
dim ReplacedString
dim RegularExpressionObject
if wscript.arguments.count <>2 then
wscript.echo "Syntax error. Usage: cscript lastfail.vbs username domain"
wscript.quit (5555)
end if
Set RegularExpressionObject=New RegExp
With RegularExpressionObject
.Pattern="CN="
.IgnoreCase=False
.Global=False
End With
userName = wscript.arguments(0)
domain = wscript.arguments(1)
Function FindNBind() 'Shamelessly stolen from Jeffrey Honneyman
dim myObj
set myObj=GetObject("LDAP://rootDSE"
FindNBind=myObj.get("defaultNamingContext"
end Function
FindNBind 'Calling the function
dom = FindNBind
concat="LDAP://OU=Domain Controllers,"& dom
set obj=GetObject(concat) 'binding to DC's Object
for each thing in obj
counter=0
tempHolder=thing.name
ReplacedString = RegularExpressionObject.Replace (tempHolder,""
dcArray(counter)=ReplacedString & "." & domain
secondConcat="LDAP://" & dcArray(counter) & "/CN=" & userName & "," & "CN=Users," & dom
set secondObj=GetObject(secondConcat)
badLogin = secondObj.get("badPasswordTime" 'this is where I get the error.
wscript.echo badLogin
counter=counter+1
next