Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
check_password_expiration.pl 26.17 KiB
#!/usr/bin/perl

# ------------------------------------------------------------------------------
# $Id$
#
# ------------------------------------------------------------------------------

use strict;
use warnings;
use Getopt::Long;
use Data::Dumper;
use Config::IniFiles;
use Net::LDAP;
use File::Copy;
use File::Basename;
use Sys::Hostname;
use DateTime;
use MIME::Lite;

# unbuffered output:
$| = 1;

use lib ( new Config::IniFiles( -file => "/opt/etc/ini/global.ini" )->val( 'APPLICATION', 'LIBRARY' ) );

BEGIN {
    my $iniFile = new Config::IniFiles( -file => "/opt/etc/ini/global.ini" );
    push( @INC, $iniFile->val( 'APPLICATION', 'LIBRARY' ) );
}

use SNET::common;
use SNET::snmpd;
use SNET::LdapNS qw(:all);
use DateTime::Format::LDAP;

use vars qw($verbose $debug $help $force $cli_mode $dry_run );
$verbose  = 0;
$debug    = 0;
$cli_mode = 1;

my $PROGNAME = basename( $0 );
$PROGNAME =~ s/\.p[lm]$//;

my %options = (
                "help"    => \$help,
                "debug"   => \$debug,
                "verbose" => \$verbose,
                "force"   => \$force,
                "dry-run" => \$dry_run,
);

my $SNMP_ENTERPRISEOID = "53";
my $SNMP_OID           = "1.3.6.1.4.1.99999.$SNMP_ENTERPRISEOID";
my $SNMP_GEN           = "6";
my $SNMP_SPE           = "1";
my $msg                = '';
my $title              = "Check Password";

help() if !GetOptions( %options ) or $help;
$verbose = 1 if $debug;

metaprint( 'warning', "Dry-run is activated, no email." ) if $dry_run;

# ldap_find_users_and_groups()
#
# Read users and groups from SNet LDAP.

sub ldap_find_users_in_group ($$$$$$$$$$)
{
    my (
         $cfg_ldap_server,              $cfg_ldap_user,            $cfg_ldap_passwd,    $cfg_ldap_group_search, $cfg_ldap_search_scope,