Commit 55c5557a authored by Côme Chilliet's avatar Côme Chilliet

🚑 fix(user-reminder) Fix supannRessourceEtatDate checking

Multivalue was incorrectly handled and date was not parsed correctly.
user-reminder now depends upon DateTime perl library (libdatetime-perl
 on Debian)

issue #5744
parent 2f6ea3d3
......@@ -40,6 +40,8 @@ use Mail::Sendmail qw(sendmail);
use MIME::Base64;
use MIME::Words qw(encode_mimewords);
use DateTime;
my $config;
$config = argonaut_read_config;
......@@ -283,11 +285,25 @@ sub check_expired_users
foreach my $entry ($mesg->entries()) {
my $cn = $entry->get_value('cn');
my ($labelstate, $substate, $start, $end) = split(':', $entry->get_value('supannRessourceEtatDate'));
if ($end < $now) {
print "$cn has an invalid supannRessourceEtatDate value\n" if $verbose;
} elsif ($end <= $next_alert_date) {
alert_user_if_needed($ldap,$entry,$now,0);
foreach my $supannRessourceEtatDate ($entry->get_value('supannRessourceEtatDate')) {
my ($labelstate, $substate, $start, $end) = split(':', $supannRessourceEtatDate);
if ($labelstate ne '{COMPTE}A') {
next;
}
if ($end eq '') {
next;
}
my $dt = DateTime->new(
year => substr($end, 0, 4),
month => substr($end, 4, 2),
day => substr($end, 6, 2),
);
my $endInSeconds = $dt->epoch;
if ($endInSeconds < $now) {
print "$cn has an invalid supannRessourceEtatDate value\n" if $verbose;
} elsif ($endInSeconds <= $next_alert_date) {
alert_user_if_needed($ldap,$entry,$now,0);
}
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment