I have a program that runs some validations on objects in active directory and one of my checks is to see if the expiry date is set within a year. With a UserPrincipal
object I can check the .AccountExpirationDate
date to see if it has one but how would I look at that date to see if it's set to expire within a year?
This is currently what I'm rolling with
protected Check AccountExpiresMandatoryCheck = new Check()
{
ResultMessageTemplate = "User(s) don't have an expiry date or expiry date is greater than 1 year",
Run = delegate(Principal principal, AccountPoint point)
{
UserPrincipal user = principal as UserPrincipal;
if (user == null) return false;
return user.AccountExpirationDate != null || //check here if the date is a year or less;
}
};
I realize stuff like a Check
and AccountPoint
are custom objects made by me but I'm hoping that won't prevent anyone from answering my question of;
How would I check if the expiry date was set to be a year or less