lastLogonTimeStamp object returned by OLE DB provider ADsDSOObject SQL Query in Access VBA
I have searched a fair bit for an answer to this, but come up blank. I know it's a fairly obscure question, but I thought I'd put it out there...
NOTE I don't need info about how to convert lastlogonTimeStamp to a date or details of its structure - that's all good,
What I have is some VBA code e.g:
sBase = "LDAP://OU=Computers,OU=[our organisational unit, etc],DC=OURDOMAIN,DC=WIN"
' Open the connection.
oConnection1.Provider = "ADsDSOObject" ' This is the ADSI OLE-DB provider name
oConnection1.Open "Active Directory Provider"
' Create a command object for this connection.
Set oCommand1.ActiveConnection = oConnection1
SQL = "SELECT name, lastLogonTimeStamp, whenChanged, distinguishedName FROM '" & sBase & "'
oCommand1.CommandText = SQL
Set rs = oCommand1.Execute
The lastlogonTimeStamp value is returned as a accessible field in the recordset as expected, but I have yet to find a way to access its actual value.
(whenChanged is returned as a date, the others as strings)
Every thing I've tried comes up with a compile or run error etc.
The obvious ones like CLngLng, CDate, Cstr, ToString() give "Object doesn't support this property or method".
Using Set ads = rs!LastLogonTimeStamp (ads is an ActiveDS.LargeInteger) gives a Type Mismatch error
.HighPart and .LowPart give method or data member not found
VarType() returns vbObject
The workaround is to use
Set oComputer = GetObject(rs!distinguishedName)
Set ads = oComputer.LastlogonTimeStamp
But the GetObject takes extra time and slows down the loop through the recordset a lot.
Is there some secret to accessing the lastLogonTimeStamp LargeInteger value (HighPart and LowPart) ?