lastLogonTimeStamp object returned by OLE DB provider ADsDSOObject SQL Query in Access VBA

N H 1 Reputation point
2022-07-06T07:38:11.157+00:00

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) ?

Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
897 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.