For main email and attr_map, only take the first value
This commit is contained in:
parent
63b75db468
commit
0e6b214078
|
@ -295,13 +295,14 @@ DOMAIN: foreach my $domain ( keys $conf->{domains} ) {
|
|||
|
||||
log_verbose( "Comparing the accounts" );
|
||||
|
||||
my $single = map { $conf->{domains}->{$domain}->{users}->{attr_map}->{$_} }
|
||||
keys $conf->{domains}->{$domain}->{users}->{attr_map};
|
||||
push @single, $conf->{domains}->{$domain}->{users}->{mail_attr};
|
||||
my $ext_users = ldap2hashref(
|
||||
$ext_user_search,
|
||||
$conf->{domains}->{$domain}->{users}->{key},
|
||||
(
|
||||
$conf->{domains}->{$domain}->{users}->{mail_attr},
|
||||
$conf->{domains}->{$domain}->{users}->{alias_attr}
|
||||
)
|
||||
( $conf->{domains}->{$domain}->{users}->{alias_attr} ),
|
||||
@single
|
||||
);
|
||||
my $zim_users = ldap2hashref(
|
||||
$zim_user_search,
|
||||
|
@ -496,14 +497,18 @@ DOMAIN: foreach my $domain ( keys $conf->{domains} ) {
|
|||
" distribution list(s) in Zimbra" );
|
||||
log_verbose( "Comparing groups with distribution lists" );
|
||||
|
||||
my @single = map { $conf->{domains}->{$domain}->{groups}->{attr_map}->{$_} }
|
||||
keys $conf->{domains}->{$domain}->{groups}->{attr_map};
|
||||
push @single, $conf->{domains}->{$domain}->{groups}->{mail_attr};
|
||||
|
||||
my $ext_groups = ldap2hashref(
|
||||
$ext_group_search,
|
||||
$conf->{domains}->{$domain}->{groups}->{key},
|
||||
(
|
||||
$conf->{domains}->{$domain}->{groups}->{members_attr},
|
||||
$conf->{domains}->{$domain}->{groups}->{mail_attr},
|
||||
$conf->{domains}->{$domain}->{groups}->{alias_attr}
|
||||
)
|
||||
),
|
||||
@single
|
||||
);
|
||||
my $zim_dl = ldap2hashref(
|
||||
$zim_dl_search,
|
||||
|
@ -738,19 +743,24 @@ sub handle_error {
|
|||
# * An LDAP search result
|
||||
# * The attribute used as the key of objects
|
||||
# * An optional array of attributes we want as an array, even if there's a single value
|
||||
# * An optional array of attributes we want single valued. Return the first value if several are provided
|
||||
# It'll return a hashref. The key will be unaccentuated and lower cased.
|
||||
|
||||
sub ldap2hashref {
|
||||
my ( $search, $key, @want_array ) = @_;
|
||||
my ( $search, $key, @want_array, @want_single ) = @_;
|
||||
my $return = {};
|
||||
|
||||
foreach my $entry ( $search->entries ) {
|
||||
$return->{unidecode( lc $entry->get_value($key) )}->{dn} = $entry->dn;
|
||||
foreach my $attr ( $entry->attributes ) {
|
||||
my @values = $entry->get_value($attr);
|
||||
$return->{unidecode( lc $entry->get_value($key) )}->{$attr} = ( scalar @values == 1 ) ?
|
||||
( grep { $attr eq $_ } @want_array ) ? \@values : $values[0] :
|
||||
\@values;
|
||||
if ( grep { $attr eq $_ } @want_array ) {
|
||||
$return->{unidecode( lc $entry->get_value($key) )}->{$attr} = \@values;
|
||||
} elsif ( grep { $attr eq $_ } @want_single ) {
|
||||
$return->{unidecode( lc $entry->get_value($key) )}->{$attr} = $values[0];
|
||||
} else {
|
||||
$return->{unidecode( lc $entry->get_value($key) )}->{$attr} = ( scalar @values == 1 ) ?
|
||||
\@values : $values[0];
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
|
|
Loading…
Reference in New Issue