From 593c1f42d337fa62db25794161caa61db9a6c987 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 8 Oct 2020 11:40:41 +0200 Subject: [PATCH] Replace spaces with a dash (mainly for group -> distribution list) --- zmldapsync/zmldapsync.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) mode change 100644 => 100755 zmldapsync/zmldapsync.pl diff --git a/zmldapsync/zmldapsync.pl b/zmldapsync/zmldapsync.pl old mode 100644 new mode 100755 index c343eca..7f236f2 --- a/zmldapsync/zmldapsync.pl +++ b/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; } } }