Dedup LDAP aliases in zimbraNotes

master
Daniel Berteaud 5 years ago
parent fe34c0ddf0
commit f6f14a81c5
  1. 4
      zmldapsync/zmldapsync.pl

@ -9,6 +9,7 @@ use Getopt::Long;
use Data::UUID; use Data::UUID;
use String::ShellQuote qw(shell_quote); use String::ShellQuote qw(shell_quote);
use Array::Diff; use Array::Diff;
use List::MoreUtils qw(uniq);
use Hash::Merge::Simple qw(merge); use Hash::Merge::Simple qw(merge);
use Text::Unidecode; use Text::Unidecode;
use Email::MIME; use Email::MIME;
@ -388,7 +389,7 @@ DOMAIN: foreach my $domain ( keys $conf->{domains} ) {
@{ $ext_users->{$user}->{$conf->{domains}->{$domain}->{users}->{$mail_attr}} }; @{ $ext_users->{$user}->{$conf->{domains}->{$domain}->{users}->{$mail_attr}} };
} }
@ext_aliases = sort @ext_aliases; @ext_aliases = sort uniq @ext_aliases;
foreach my $alias ( @ext_aliases ) { foreach my $alias ( @ext_aliases ) {
next if ( not alias_matches_domain( $alias, $domain_entry ) ); next if ( not alias_matches_domain( $alias, $domain_entry ) );
@ -630,6 +631,7 @@ DOMAIN: foreach my $domain ( keys $conf->{domains} ) {
push @ext_aliases, push @ext_aliases,
@{ $ext_groups->{$group}->{$conf->{domains}->{$domain}->{groups}->{$mail_attr}} }; @{ $ext_groups->{$group}->{$conf->{domains}->{$domain}->{groups}->{$mail_attr}} };
} }
@ext_aliases = sort uniq @ext_aliases;
foreach my $alias ( @ext_aliases ) { foreach my $alias ( @ext_aliases ) {
next if ( not alias_matches_domain( $alias, $domain_entry ) ); next if ( not alias_matches_domain( $alias, $domain_entry ) );
next if ( grep { $alias eq $_ } @{ $zim_dl->{$group}->{mail} } ); next if ( grep { $alias eq $_ } @{ $zim_dl->{$group}->{mail} } );

Loading…
Cancel
Save