One of the classes is TJwADUser that represents an Active Directory user with all kinds of properties. So while I was implementing them I stumbled upon the accountExpires attribute which is implemented as an 8 byte integer so I figured I could read it as Int64, cast this to TFileTime (FILETIME) and convert to TDateTime.
This raised an error however (EVariantTypeCastError with message ‘Could not convert variant of type (Dispatch) into type (Double)’.).
So I checked what kind of variant Active Directory returns and it is not the expected varInt64 but varDispatch.
It turns out that we need the IADsLargeInteger interface to obtain the correct values. The code below works for me:
function TJwADUser.GetExpirationDate: TDateTime;
if Get('accountExpires', v) then
LargeInteger := IDispatch(v) as IADsLargeInteger;
ft.dwLowDateTime := LargeInteger.LowPart;
ft.dwHighDateTime := LargeInteger.HighPart;
if Int64(ft) = 0 then
Result := 0
Result := FileTime2DateTime(ft)
Result := 0;
Notes: The Get function is a wrapper for IADs(User).Get(Ex) so you can ignore that and my function returns 0 when the value is empty or on read failure.