|
|
@ -295,13 +295,14 @@ DOMAIN: foreach my $domain ( keys $conf->{domains} ) { |
|
|
|
|
|
|
|
|
|
|
|
log_verbose( "Comparing the accounts" ); |
|
|
|
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( |
|
|
|
my $ext_users = ldap2hashref( |
|
|
|
$ext_user_search, |
|
|
|
$ext_user_search, |
|
|
|
$conf->{domains}->{$domain}->{users}->{key}, |
|
|
|
$conf->{domains}->{$domain}->{users}->{key}, |
|
|
|
( |
|
|
|
( $conf->{domains}->{$domain}->{users}->{alias_attr} ), |
|
|
|
$conf->{domains}->{$domain}->{users}->{mail_attr}, |
|
|
|
@single |
|
|
|
$conf->{domains}->{$domain}->{users}->{alias_attr} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
my $zim_users = ldap2hashref( |
|
|
|
my $zim_users = ldap2hashref( |
|
|
|
$zim_user_search, |
|
|
|
$zim_user_search, |
|
|
@ -496,14 +497,18 @@ DOMAIN: foreach my $domain ( keys $conf->{domains} ) { |
|
|
|
" distribution list(s) in Zimbra" ); |
|
|
|
" distribution list(s) in Zimbra" ); |
|
|
|
log_verbose( "Comparing groups with distribution lists" ); |
|
|
|
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( |
|
|
|
my $ext_groups = ldap2hashref( |
|
|
|
$ext_group_search, |
|
|
|
$ext_group_search, |
|
|
|
$conf->{domains}->{$domain}->{groups}->{key}, |
|
|
|
$conf->{domains}->{$domain}->{groups}->{key}, |
|
|
|
( |
|
|
|
( |
|
|
|
$conf->{domains}->{$domain}->{groups}->{members_attr}, |
|
|
|
$conf->{domains}->{$domain}->{groups}->{members_attr}, |
|
|
|
$conf->{domains}->{$domain}->{groups}->{mail_attr}, |
|
|
|
|
|
|
|
$conf->{domains}->{$domain}->{groups}->{alias_attr} |
|
|
|
$conf->{domains}->{$domain}->{groups}->{alias_attr} |
|
|
|
) |
|
|
|
), |
|
|
|
|
|
|
|
@single |
|
|
|
); |
|
|
|
); |
|
|
|
my $zim_dl = ldap2hashref( |
|
|
|
my $zim_dl = ldap2hashref( |
|
|
|
$zim_dl_search, |
|
|
|
$zim_dl_search, |
|
|
@ -738,19 +743,24 @@ sub handle_error { |
|
|
|
# * An LDAP search result |
|
|
|
# * An LDAP search result |
|
|
|
# * The attribute used as the key of objects |
|
|
|
# * 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 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. |
|
|
|
# It'll return a hashref. The key will be unaccentuated and lower cased. |
|
|
|
|
|
|
|
|
|
|
|
sub ldap2hashref { |
|
|
|
sub ldap2hashref { |
|
|
|
my ( $search, $key, @want_array ) = @_; |
|
|
|
my ( $search, $key, @want_array, @want_single ) = @_; |
|
|
|
my $return = {}; |
|
|
|
my $return = {}; |
|
|
|
|
|
|
|
|
|
|
|
foreach my $entry ( $search->entries ) { |
|
|
|
foreach my $entry ( $search->entries ) { |
|
|
|
$return->{unidecode( lc $entry->get_value($key) )}->{dn} = $entry->dn; |
|
|
|
$return->{unidecode( lc $entry->get_value($key) )}->{dn} = $entry->dn; |
|
|
|
foreach my $attr ( $entry->attributes ) { |
|
|
|
foreach my $attr ( $entry->attributes ) { |
|
|
|
my @values = $entry->get_value($attr); |
|
|
|
my @values = $entry->get_value($attr); |
|
|
|
|
|
|
|
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 ) ? |
|
|
|
$return->{unidecode( lc $entry->get_value($key) )}->{$attr} = ( scalar @values == 1 ) ? |
|
|
|
( grep { $attr eq $_ } @want_array ) ? \@values : $values[0] : |
|
|
|
\@values : $values[0]; |
|
|
|
\@values; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return $return; |
|
|
|
return $return; |
|
|
|