Adldap2-Laravel
Adldap2-Laravel copied to clipboard
Improve BindException "Can't contact LDAP server"
- Laravel Version: 6.5 (not relevant; doesn't matter)
- Adldap2-Laravel Version: 6.0.8
- PHP Version: 7.2 (not relevant; doesn't matter)
- LDAP Type: ActiveDirectory (not relevant; doesn't matter)
Description:
When this library is unable to bind to the AD or any other LDAP server, it throws the BindException
"Can't contact LDAP server".
Especially when you're trying to get a SSL connection working, this is really hard to debug.
Is it possible to add somehow the real reason (eg. certificate verify failed
) for the BindException
to the exception message or at least to the logs?
This would help everyone here to debug such issues much more easy in the future.
In best case, those error reasons will be always logged - even when logging is disabled.
I would expect something like this in the exception message or in the logs:
Can't contact LDAP server: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (unable to get local issuer certificate))
You usually get such error messages when you execute a PHP script from a command line with ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
.
But ldap_error( resource $link_identifier )
should return the same result: https://www.php.net/manual/en/function.ldap-error.php
Steps To Reproduce:
Just configure some wrong LDAP connection settings and try to get any kind of information from the LDAP server.
I agree with you - this should definitely be implemented.
I'll accept a PR, or you can give me a couple days to give this a shot to implement.
I didn't found a solution yet, but I found this: https://github.com/Adldap2/Adldap2/issues/708
Which is already kinda useful.