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.
synchronize_proteus_Users.pl 22.50 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;

# 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 SNET::libsoap;

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 = "99";
my $SNMP_OID           = "1.3.6.1.4.1.99999.$SNMP_ENTERPRISEOID";
my $SNMP_GEN           = "6";
my $SNMP_SPE           = "1";
my $msg                = '';
my $title              = "Proteus ImportUser";

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

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

sub ldap_find_users_and_groups ($$$$$$$$$$)
{
    my (
         $cfg_ldap_server,              $cfg_ldap_user,            $cfg_ldap_passwd,    $cfg_ldap_group_search, $cfg_ldap_search_scope,
         $cfg_ldap_group_search_filter, $cfg_ldap_group_attribute, $cfg_ldap_groupname, $hostname,              $cfg_ldap_cafile
    ) = @_;

    my %users;