Add some debug messages
This commit is contained in:
parent
aa7efab83f
commit
dd3445ca95
3 changed files with 24 additions and 8 deletions
17
ACU/LDAP.pm
17
ACU/LDAP.pm
|
|
@ -128,7 +128,7 @@ sub get_dn($$@)
|
|||
scope => "base"
|
||||
);
|
||||
if ($mesg->code != 0) { ACU::Log::do_warn($mesg->error); return undef; }
|
||||
if ($mesg->count != 1) { ACU::Log::do_warn("$cn not found or multiple entries match"); return undef; }
|
||||
if ($mesg->count != 1) { ACU::Log::do_warn("$dn not found or multiple entries match"); return undef; }
|
||||
|
||||
return $mesg->entry(0);
|
||||
}
|
||||
|
|
@ -145,7 +145,7 @@ sub add_attribute($$$@)
|
|||
my @data = $entry->get_value($what);
|
||||
for my $value (@_)
|
||||
{
|
||||
if (! grep(/^$value$/, @data)) {
|
||||
if (! grep("^$value\$", @data)) {
|
||||
$mod = 1;
|
||||
|
||||
ACU::Log::do_debug("Add attribute $value to $dn");
|
||||
|
|
@ -160,7 +160,7 @@ 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("$cn not found or multiple entries match"); return 0; }
|
||||
if ($mesg->count != 1) { ACU::Log::do_warn("$dn not found or multiple entries match"); return 0; }
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -181,12 +181,15 @@ sub delete_attribute($$$@)
|
|||
my @data = $entry->get_value($what);
|
||||
for my $value (@_)
|
||||
{
|
||||
if (grep(/^$value$/, @data)) {
|
||||
if (grep("^$value\$", @data)) {
|
||||
ACU::Log::do_debug("Remove attribute $what ($value) from $dn");
|
||||
|
||||
@data = grep(!/$value$/, @data);
|
||||
@data = grep(!"^$value\$", @data);
|
||||
$mod = 1;
|
||||
}
|
||||
else {
|
||||
ACU::Log::do_warn("No attribute $what with value $value for $dn");
|
||||
}
|
||||
}
|
||||
|
||||
if ($mod)
|
||||
|
|
@ -217,7 +220,7 @@ sub flush_attribute($$@)
|
|||
my $ldap = shift // ldap_connect();
|
||||
my $dn = shift;
|
||||
|
||||
$ldap->modify($dn, delete => \@_)->code;
|
||||
my $mesg = $ldap->modify($dn, delete => \@_)->code;
|
||||
|
||||
if ($mesg->code != 0) { ACU::Log::do_warn($mesg->error); return 0; }
|
||||
|
||||
|
|
@ -250,7 +253,7 @@ sub search_dn($$@)
|
|||
scope => "sub"
|
||||
);
|
||||
if ($mesg->code != 0) { ACU::Log::do_warn($mesg->error); return undef; }
|
||||
if ($mesg->count != 1) { ACU::Log::do_warn("$cn not found or multiple entries match"); return undef; }
|
||||
if ($mesg->count != 1) { ACU::Log::do_warn("$filter not found or multiple entries match"); return undef; }
|
||||
|
||||
return $mesg->entry(0)->dn;
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue