Archived
1
0
Fork 0

Add some debug messages

This commit is contained in:
Mercier Pierre-Olivier 2013-09-03 08:07:02 +02:00
commit dd3445ca95
3 changed files with 24 additions and 8 deletions

View file

@ -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;
}