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

master
Daniel Berteaud 4 years ago
parent 15bfb7cd4a
commit 593c1f42d3
  1. 12
      zmldapsync/zmldapsync.pl

@ -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;
}
}
}

Loading…
Cancel
Save