Try this for domain policy enforced pwd. aging.
public static void Main() {
long maxAge;
// Get maxPwdAge from domain
using(DirectoryEntry domain = new
DirectoryEntry("LDAP://domain/DC=xxxx,DC=xxxx,DC=xxx", "xxx\\administrator",
"ppppp"))
{
LargeInteger liMaxAge =domain.Properties["MaxPwdAge"].Value as
LargeInteger;
maxAge = (((long)(liMaxAge.HighPart) << 32) + (long) liMaxAge.LowPart);
// SHOULD be a negative value !!!
}
// Get pwdlast set for user (here administrator)
DirectoryEntry user = new
DirectoryEntry("LDAP://domain/CN=administrator,cn=users,DC=celeb,DC=w2kdom,DC=com",
"xxx\\administrator", "xxxxx");
LargeInteger li = user.Properties["pwdLastSet"].Value as LargeInteger;
long expDate = (((long)(li.HighPart) << 32) + (long) li.LowPart) - maxAge;
// !!! maxAge is negative number!!!
LiToDate(expDate);
}
}
static void LiToDate(long date)
{
Console.WriteLine(date);
string dt = DateTime.FromFileTime(date).ToString(); // To file time
Console.WriteLine("DATE = {0

}" ,dt); // show pwd expiry date
}
....
Willy.