#/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 }