I am using a DirectorySearcher
filter that does not work, most probably because of a wrong form of accountExpires
attribute from Active Directory. I would like to find all expired accounts using LDAP, but how can I convert DateTime.Now
to accountExpires
format? I have found lots on converting accountExpires
to Datetime
format but not the other way around. For example, I have found an example that says :
129383640000000000 is equivalent to Sat, 01 Jan 2011 14:00:00 GMT
How can I do it the other way? I know it is the interval of 100 nanoseconds from 1 JAn 1601 , but don't know how to calculate this
You need to convert it to FILETIME, as per the specification :
DateTime dt = DateTime.Now.AddDays(30);
long ftAccountExpires = dt.ToFileTime();
In the above example, if you set accountExpires
to the value of ftAccountExpires
, the account will expire 30 days from now
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.