Ok. So I\'m trying to find a way to avoid including ActiveDs in my project because I\'m having trouble getting the dll to show up in the installer. The only reason to have i
What is wrong with this code? It should work fine:
SearchResult sr = ds.FindOne();
hacked = DateTime.FromFileTime((long)sr.Properties["pwdLastSet"][0]);
You'll need to translate the AD Long Integer like this and you shouldn't need ActiveDs anymore:
long pwdLastSet = CovertADSLargeIntegerToInt64(oUser.Properties["pwdLastSet"].Value);
public static Int64 ConvertADSLargeIntegerToInt64(object adsLargeInteger)
{
var highPart = (Int32)adsLargeInteger.GetType().InvokeMember("HighPart", System.Reflection.BindingFlags.GetProperty, null, adsLargeInteger, null);
var lowPart = (Int32)adsLargeInteger.GetType().InvokeMember("LowPart", System.Reflection.BindingFlags.GetProperty, null, adsLargeInteger, null);
return highPart * ((Int64)UInt32.MaxValue + 1) + lowPart;
}