richard
8/1/2008 10:13:00 PM
Richard,
Is is possible to get the lastLogon field using this method?
I've adapted the script from your site and can now get the mail, but not the lastLogon field which
I've seen used elsewhere. It always gives an error 'Object doesn't support this property or
method', even though I know that some of the users have certainly logged in.
The key bits of the script, as far as I know, are:
strAttributes = "sAMAccountName,cn,mail,lastLogon"
.
.
.
' Write the resulting recordset to file
Do Until adoRecordset.EOF
' Retrieve values and display.
strName = adoRecordset.Fields("sAMAccountName").Value
strCN = adoRecordset.Fields("cn").value
strMail= adoRecordset.Fields("mail").value
On error resume Next
strLastLogon= adoRecordset.Fields("lastLogon").value
if Err<>0 then
sLastLogonErrorMsg=replace(replace(Err.description,vbCr,""),vbLf,"")
else
sLastLogonErrorMsg="ok"
end if
Err.clear
On error goto 0
OutputLine = strName & ";" & strCN & ";" & strMail & ";" & strLastLogon & ";" &
sLastLogonErrorMsg
Wscript.Echo OutputLine
objOutputFile.WriteLine(OutputLine )
adoRecordset.MoveNext
Loop
As I mentioned, if I don't try to get the lastLogon, everything works.
Thanks for any help,
Richard