If you use the DirectoryEntry, it marshals the value as an ADSI IADsLargeInteger type, which at runtime is a System.__ComObject. This is annoying, but you can get the value with a little interop and some data munging. This works for me: dim entry as new DirectoryEntry("LDAP://yourdn here") dim pwd as object = entry.Properties("lastLogon").Value dim pwdDate as DateTime pwdDate = DateTime.FromFileTimeUtc(GetInt64FromLargeInteger(pwd)) Function GetInt64FromLargeInteger(byval largeInteger as Object) as Int64 dim low as int32 dim high as int32 dim valBytes(7) as byte dim longInt as IADsLargeInteger = Ctype(largeInteger, IADsLargeInteger) low = longInt.LowPart high = longInt.HighPart BitConverter.GetBytes(low).CopyTo(valBytes, 0) BitConverter.GetBytes(high).CopyTo(valBytes, 4) Return BitConverter.ToInt64(valBytes, 0) End Function <ComImport(), Guid("9068270b-0939-11D1-8be1-00c04fd8d503"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsDual)> _ public interface IADsLargeInteger property HighPart as int32 property LowPart as int32 end interface
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
9 Experts available now in Live!