Commit d2bfd021 authored by Côme Chilliet's avatar Côme Chilliet

Merge branch '5744-add-supann-2018-account-life-cyle-support-in-user-reminder' into '1.3-dev'

Resolve "Add SupAnn 2018 account life cyle support in user-reminder"

See merge request argonaut/argonaut!114
parents a67cf955 55c5557a
......@@ -40,21 +40,23 @@ use Mail::Sendmail qw(sendmail);
use MIME::Base64;
use MIME::Words qw(encode_mimewords);
use DateTime;
my $config;
$config = argonaut_read_config;
$config->{'fd_rdn'} = 'ou=fusiondirectory';
my $verbose = 0;
my $posix = 1;
my $ppolicy = 1;
my $posix = 0;
my $ppolicy = 0;
my $supann = 0;
sub print_usage
{
my ($help) = @_;
print "Usage : argonaut-user-reminder [--help] [--verbose] [--posix|--ppolicy|--both (default)|--supann]\n";
print "Usage : argonaut-user-reminder [--help] [--verbose] [--posix] [--ppolicy] [--supann] [--all]\n";
if ($help) {
print << "EOF";
......@@ -62,8 +64,8 @@ sub print_usage
--verbose : be verbose
--posix : check POSIX account expiration
--ppolicy : check ppolicy password expiration
--both : check both POSIX and ppolicy (default)
--supann : check supannRessourceEtatDate
--all : check POSIX, ppolicy and supannRessourceEtatDate
EOF
exit(0);
} else {
......@@ -76,13 +78,14 @@ foreach my $arg ( @ARGV ) {
$verbose = 1;
} elsif (lc($arg) eq "--posix") {
$posix = 1;
$ppolicy = 0;
} elsif (lc($arg) eq "--ppolicy") {
$posix = 0;
$ppolicy = 1;
} elsif (lc($arg) eq "--both") {
} elsif (lc($arg) eq "--supann") {
$supann = 1;
} elsif (lc($arg) eq "--all") {
$posix = 1;
$ppolicy = 1;
$supann = 1;
} elsif ((lc($arg) eq "--help") || (lc($arg) eq "-h")) {
print_usage(1);
} else {
......@@ -90,6 +93,13 @@ foreach my $arg ( @ARGV ) {
}
}
if (!$posix && !$ppolicy && !$supann) {
# Defaults to --all
$posix = 1;
$ppolicy = 1;
$supann = 1;
}
check_expired_users();
exit 0;
......@@ -275,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