My sysadmin has failed to actually expire passwords in AD and now my password expiry warning system is starting to count back up instead of showing negative days. I'm expecting remainingDays to be a negative number for my test account ( 5 days pseudo-expired) from the following code, hoping someone can show me why I'm losing the negative. From what I've read on MSDN, DateTime.Subtract
can return negative values.
DateTime today = DateTime.Now;
foreach (User user in users)
{
DateTime expiryDate = user.pwdLastReset.AddDays(180); //pwd expires every 180 days
int remainingDays = Int32.Parse(expiryDate.Subtract(today).ToString("%d"));
//snipped code to send warnings at different days remaining.
}