//--------------------------------------------------------------------------------------------------------------------- /// <summary>Performs the background action for the password expiration check.</summary> /// <param name="context">The execution environment context.</param> /// <remarks> /// The background agent action <em>Password expiration check</em> deactivates user accounts for which the password has not been set for longer than the password expiration time (see <see cref="PasswordExpireTime"/>. /// Users can still use their accounts after setting a new password. /// </remarks> public static void ExecutePasswordExpirationCheck(IfyContext context) { if (context.DebugLevel >= 3) { context.WriteDebug(3, "PasswordExpireTime seconds: " + passwordExpireTime); } if (passwordExpireTime <= 0) { return; } DateTime earliestTime = context.Now.AddSeconds(-passwordExpireTime); string sql = String.Format("UPDATE usr SET status={0} WHERE status={1} AND allow_password AND (last_password_change_time IS NULL OR last_password_change_time<'{2}');", AccountStatusType.Deactivated, AccountStatusType.Enabled, earliestTime.ToString(@"yyyy\-MM\-dd HH\:mm\:ss")); context.WriteDebug(3, sql); int count = context.Execute(sql); context.WriteInfo("Deactivated user accounts: " + (count <= 0 ? "0" : count.ToString())); }