Look up when password was last set



Hello,

I'm writing a script to look up user account info from AD and I'm
having a problem with getting when the password was last set.
------------
'On Error Resume Next
strUsername = "username"
Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = "SELECT Name, whenCreated, pwdLastSet FROM
'LDAP://dc=corp,dc=acme,dc=local' WHERE objectCategory='user' " & "AND
sAMAccountName='" & strUsername & "'"
Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo "Name: " & objRecordSet.Fields("Name").Value
Wscript.Echo "Created: " &
objRecordSet.Fields("whenCreated").Value
Wscript.Echo "Pasword set: " &
objRecordSet.Fields("pwdLastSet").Value
objRecordSet.MoveNext
Loop
------------------------------------

Name and whenCreated come up just fine. But pwdLastSet I get an
error.
Line: 21, Char: 5, Error: Object doesn't support this property method,
Code: 800A01B6

Anyone know why I'm getting this error?

Thanks,
Joe
.



Relevant Pages

  • Re: VBS Logon and move computer script
    ... tested the script below, but it uses ADO to retrieve info on all computer ... Set objConnection = CreateObject ... Set objRecordSet = Nothing ... > Wscript.Echo strComputer & "Computer exists in Computers" ...
    (microsoft.public.windows.server.scripting)
  • Re: Look up when password was last set
    ... Set objConnection = CreateObject ... objCommand.CommandText = "SELECT Name, whenCreated, pwdLastSet FROM ... The problem is that pwdLastSet is datatype Integer8, ... where lngTZBias is the local time zone bias in minutes and Integer8Date is ...
    (microsoft.public.scripting.vbscript)
  • Re: Adding Multiple Users to Multiple Groups.
    ... then did not pull the array content down to the second part of the script. ... Finance Managers and Department Managers groups: ... Set objConnection = CreateObject ...
    (microsoft.public.scripting.vbscript)
  • Re: Get ADsPath W2K user
    ... I run the script in which I have adapted according to your suggestions, ... Set objConnection = CreateObject ... WScript.Echo strField ... I am trying to search a Windows 2000 domain for users, ...
    (microsoft.public.scripting.vbscript)
  • Re: Cross Child-Domain Scripting
    ... OR to be able to span child domain LDAP look ups in the same script. ... Set objConnection = CreateObject ... If Err = "0" Then ...
    (microsoft.public.scripting.vbscript)