initial commit

This commit is contained in:
2019-10-16 18:49:27 +02:00
commit 9b1a298478

38
test.pl Normal file
View File

@@ -0,0 +1,38 @@
#/usr/bin/perl
# on abandonne python pour perl
# ce script est capable de rajouter l'attribut description avec une valeur issue
# d'un fichier csv passé en argument
use strict;
use Net::LDAP;
my $ldapserver = "localhost";
my $binddn = "cn=manager,o=od";
my $bindpw = "123Soleil" ;
my $ldap = Net::LDAP->new( $ldapserver ) or die "$@" ;
my $mesg = $ldap->bind( $binddn,
password => $bindpw
);
$mesg->code and die $mesg->error; # check for errors
my $file = $ARGV[0] or die "Need to get CSV file on the command line\n" ;
open(my $data, '<', $file) or die "Could not open '$file' $!\n";
while (my $line = <$data>) {
chomp $line;
my @fields = split ";" , $line;
my $dn = $fields[0] ;
my $attr1 = $fields[1] ;
print( $dn."\t".$attr1."\n" ) ;
my $mesg = $ldap-> modify( $dn,
changes=> [
delete => [ 'description' ],
add => [ description => $attr1 ]
]
) ;
$mesg->code and warn $mesg->error; # check for errors
}