From https://stackoverflow.com/questions/18614810/how-to-convert-active-directory-pwdlastset-to-date-time
According to the MSDN documentation:
This value is stored as a large integer that represents the number of 100 nanosecond intervals since January 1, 1601 (UTC).
This aligns perfectly with
DateTime.FromFileTimeUtc
, as described here.
And I'm not sure why you feel the need to do the low level manipulation of the integer. I think you could just cast it.
So just do:
long value = (long)objResult.Properties["pwdLastSet"][0];
DateTime pwdLastSet = DateTime.FromFileTimeUtc(value);
沒有留言:
張貼留言