Commit b828a4bf authored by Côme Chilliet's avatar Côme Chilliet
Browse files

🚑 fix(ldap) Use ldap_err2str to avoid empty error message

When an LDAP server returns an error code but no error message, use
 ldap_err2str to generate a generic error message depending on the error
 code, to avoid returning an empty error message.
For instance when refusing to delete a cn=config subobject, openldap
 will return 53 error code with no error message.

issue #1
parent 1b9b0ff3
Pipeline #9028 passed with stages
in 18 seconds
......@@ -99,7 +99,12 @@ class Result implements \Iterator,\Countable
public function assert (): void
{
if ($this->errcode != 0) {
$errmsg = $this->errmsg.' ('.$this->errcode.')';
if ($this->errmsg == '') {
$errmsg = ldap_err2str($this->errcode);
} else {
$errmsg = $this->errmsg;
}
$errmsg .= ' ('.$this->errcode.')';
if (isset($this->matcheddn) && (strlen($this->matcheddn) > 0)) {
$errmsg .= '(matched dn: '.$this->matcheddn.')';
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment