diff --git a/ACU/LDAP.pm b/ACU/LDAP.pm index 59f0e1f..faeefe1 100644 --- a/ACU/LDAP.pm +++ b/ACU/LDAP.pm @@ -145,13 +145,16 @@ sub add_attribute($$$@) my @data = $entry->get_value($what); for my $value (@_) { - if (! grep("^$value\$", @data)) { + if (! grep { /^\Q$value\E$/ } @data) { $mod = 1; ACU::Log::do_debug("Add attribute $value to $dn"); push @data, $value; } + else { + ACU::Log::do_warn("Attribute $what with value $value for $dn already exists."); + } } if ($mod) @@ -160,7 +163,6 @@ sub add_attribute($$$@) my $mesg = $entry->update($ldap) or die $!; if ($mesg->code != 0) { ACU::Log::do_warn($mesg->error); return 0; } - if ($mesg->count != 1) { ACU::Log::do_warn("$dn not found or multiple entries match"); return 0; } return 1; } @@ -181,10 +183,10 @@ sub delete_attribute($$$@) my @data = $entry->get_value($what); for my $value (@_) { - if (grep("^$value\$", @data)) { + if (grep { /^\Q$value\E$/ } @data) { ACU::Log::do_debug("Remove attribute $what ($value) from $dn"); - @data = grep(!"^$value\$", @data); + @data = grep { ! /^\Q$value\E$/ } @data; $mod = 1; } else {