In addition to the previous answer, which shows correct code to get value from IADsLargeInteger
variable , I just want to say that there's no need to add a reference to a COM Types library if you need only this interface.
To work with COM type you can define interface in your own code:
[ComImport, Guid("9068270b-0939-11d1-8be1-00c04fd8d503"), InterfaceType(ComInterfaceType.InterfaceIsDual)]
internal interface IAdsLargeInteger
{
long HighPart
{
[SuppressUnmanagedCodeSecurity] get; [SuppressUnmanagedCodeSecurity] set;
}
long LowPart
{
[SuppressUnmanagedCodeSecurity] get; [SuppressUnmanagedCodeSecurity] set;
}
}
and use it the same way:
var largeInt = (IAdsLargeInteger)directoryEntry.Properties[propertyName].Value;
var datelong = (largeInt.HighPart << 32) + largeInt.LowPart;
var dateTime = DateTime.FromFileTimeUtc(datelong);
There's also a good article, explaining how to interpret ADSI data