diff --git a/zmldapsync/zmldapsync.pl b/zmldapsync/zmldapsync.pl index 618931e..981f4ec 100755 --- a/zmldapsync/zmldapsync.pl +++ b/zmldapsync/zmldapsync.pl @@ -562,16 +562,16 @@ DOMAIN: foreach my $domain ( keys $conf->{domains} ) { not defined $zim_dl->{$group}->{$conf->{domains}->{$domain}->{groups}->{attr_map}->{$attr}} ) { # Attr does not exist in external LDAP and in Zimbra, not need to continue next; - } elsif ( not defined $ext_groups->{$group}->{$attr} ) { + } elsif ( not defined $ext_groups->{$group}->{$attr} and defined $conf->{domains}->{$domain}->{groups}->{attr_map}->{$attr} ) { # Attr doesn't exist in external LDAP, but exists in Zimbra. We must remove it $attrs = ' -' . $conf->{domains}->{$domain}->{groups}->{attr_map}->{$attr} . " " . zim_attr_value( $zim_dl->{$group}->{$conf->{domains}->{$domain}->{groups}->{attr_map}->{$attr}} ); - } elsif ( $ext_groups->{$group}->{$attr} ne $zim_dl->{$group}->{$conf->{domains}->{$domain}->{groups}->{attr_map}->{$attr}} ) { + } elsif ( ( $ext_groups->{$group}->{$attr} || '' ) ne ( $zim_dl->{$group}->{$conf->{domains}->{$domain}->{groups}->{attr_map}->{$attr}} || '' ) ) { # Attr exists in both but doesn't match - $attrs .= " " . $conf->{domains}->{$domain}->{groups}->{attr_map}->{$attr} . " " . + $attrs .= " " . ( $conf->{domains}->{$domain}->{groups}->{attr_map}->{$attr} || '' ) . " " . zim_attr_value( $ext_groups->{$group}->{$attr} ); - log_verbose( $ext_groups->{$group}->{$attr} . " vs " . - $zim_dl->{$group}->{$conf->{domains}->{$domain}->{groups}->{attr_map}->{$attr}} ); + log_verbose( "Attribute $attr for group $group changed from " . ( $ext_groups->{$group}->{$attr} || 'an empty value' ) . " to " . + ( $zim_dl->{$group}->{$conf->{domains}->{$domain}->{groups}->{attr_map}->{$attr}} || 'an empty value' ) ); } }