Replace spaces with a dash (mainly for group -> distribution list)

This commit is contained in:
Daniel Berteaud 2020-10-08 11:40:41 +02:00
parent 15bfb7cd4a
commit 593c1f42d3
1 changed files with 7 additions and 5 deletions

12
zmldapsync/zmldapsync.pl Normal file → Executable file
View File

@ -788,16 +788,18 @@ sub ldap2hashref {
$want_single ||= [];
foreach my $entry ( $search->entries ) {
$return->{unidecode( lc $entry->get_value($key) )}->{dn} = $entry->dn;
my $val = unidecode( lc $entry->get_value($key) );
# We don't want space here !
$val =~ s/\s+/-/g;
$return->{$val}->{dn} = $entry->dn;
foreach my $attr ( $entry->attributes ) {
my @values = $entry->get_value($attr);
if ( grep { $attr eq $_ } @{ $want_array } ) {
$return->{unidecode( lc $entry->get_value($key) )}->{$attr} = \@values;
$return->{$val}->{$attr} = \@values;
} elsif ( grep { $attr eq $_ } @{ $want_single } ) {
$return->{unidecode( lc $entry->get_value($key) )}->{$attr} = $values[0];
$return->{$val}->{$attr} = $values[0];
} else {
$return->{unidecode( lc $entry->get_value($key) )}->{$attr} = ( scalar @values == 1 ) ?
$values[0] : \@values;
$return->{$val}->{$attr} = ( scalar @values == 1 ) ? $values[0] : \@values;
}
}
}