Hi,
Well, my script (below) is supposed to find all user's on the domain
which have "password cannot expire" falgged, aswell as a list of all
users (by name) who have not logged on for a month.
If we only use the line:
(userAccountControl:1.2.840.113556.1.4.803:=65536); in the LDAP search
query, the script works fine, and returns a list of all user by name.
But when (lastLogonTimeStamp<= 127751249340000000) is added in the
search, the script returns nothing,
any advice would be great appreciated.
Regards
Khurram
Orion4_@hotmail.com
'
------------------------------------------------------------------------------------------------
' UserAudit_2.vbs
' Creates a report based on AD user properties for security auditing
purposes
'
------------------------------------------------------------------------------------------------
On Error Resume Next
'set parameters for ADOB Connection
Set objADConnection = CreateObject("ADODB.Connection")
Set objADCommand = CreateObject("ADODB.Command")
objADConnection.Provider = "ADsDSOObject"
objADConnection.Open "Active Directory Provider"
Set objADCommand.ActiveConnection = objADConnection
objADCommand.Properties("Page Size") = 1000
'connect to AD using LDAP, and search for users with
'the "ADS_UF_DONT_EXPIRE_PASSWD" flag (use value 65536)
objADCommand.CommandText = _
"<LDAP://DC=rfs,DC=nsw,DC=gov,DC=au>;" & _
"(&(ObjectCategory=Person)(objectCategory=User)(lastLogonTimeStamp<=
127751249340000000)(userAccountControl:1.2.840.113556.1.4.803:=65536));"
& _
"Name;Subtree"
'Define Record set
Set rsAD = objADCommand.Execute
'start at beggining of Record Set
rsAD.MoveFirst
'Print out the names of all users in RS
Do Until rsAD.EOF
Wscript.Echo rsAD.Fields("Name").Value
rsAD.MoveNext
Loop