LSldapObject::validateAttrData(): fix checking LDAP validation result

This commit is contained in:
Benjamin Renard 2021-01-18 15:03:26 +01:00
parent 7ef6e57c49
commit 957777d44f

View file

@ -533,26 +533,27 @@ class LSldapObject extends LSlog_staticLoggerClass {
} }
// Check result // Check result
if(LSconfig :: get('result', null, 'int', $test) == 0) { $configured_result = LSconfig :: get('result', null, 'int', $test);
if($ret != 0) { if(
if ($LSform) ($configured_result == 0 && $ret != 0) ||
$LSform -> setElementError($attr, $msg_error); ($configured_result > 0 && $ret <= 0)
$retval = false; ) {
} $retval = false;
self :: log_warning(
"validateAttrData(".$LSform->idForm.", ".$attr->name."): ".
"validation with LDAP search on base DN='$sbasedn' and ".
"filter='".$sfilter->as_string()."' error ($ret object(s) found)"
);
if ($LSform)
$LSform -> setElementError($attr, $msg_error);
} }
else { else {
if($ret < 0) { self :: log_trace(
if ($LSform) "validateAttrData(".$LSform->idForm.", ".$attr->name."): ".
$LSform -> setElementError($attr, $msg_error); "validation with LDAP search on base DN='$sbasedn' and ".
$retval = false; "filter='".$sfilter->as_string()."' success ($ret object(s) found)"
} );
} }
self :: log_trace(
"validateAttrData(".$LSform->idForm.", ".$attr->name."): ".
"validation with LDAP search on base DN='$sbasedn' and ".
"filter='".$sfilter->as_string()."' success ($ret object(s) found)"
);
} }
// Validation using external function // Validation using external function
else if(isset($test['function'])) { else if(isset($test['function'])) {
@ -1884,7 +1885,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
return false; return false;
} }
// Unknown key, log warning // Unknown key, log warning
self :: log_warning("__get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context()); self :: log_warning("__get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context());
} }