feature #28424 [Ldap] Add verbose ext-ldap error if present for easier debugging (scaytrase)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Ldap] Add verbose ext-ldap error if present for easier debugging

| Q             | A
| ------------- | ---
| Branch?       | master (be careful when merging)
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   |
| Fixed tickets | #28149
| License       | MIT
| Doc PR        |

Added an optional message suffix if ldap_errno is not equals to 0

Commits
-------

761415fc1b Add verbose ext-ldap error if present for easier debugging
This commit is contained in:
Nicolas Grekas 2018-09-21 13:16:30 +02:00
commit ea2a65c271

View File

@ -89,7 +89,12 @@ class Query extends AbstractQuery
}
if (false === $this->search) {
throw new LdapException(sprintf('Could not complete search with dn "%s", query "%s" and filters "%s".', $this->dn, $this->query, implode(',', $this->options['filter'])));
$ldapError = '';
if ($errno = ldap_errno($con)) {
$ldapError = sprintf(' LDAP error was [%d] %s', $errno, ldap_error($con));
}
throw new LdapException(sprintf('Could not complete search with dn "%s", query "%s" and filters "%s".%s', $this->dn, $this->query, implode(',', $this->options['filter']), $ldapError));
}
return new Collection($this->connection, $this);