ZF-11282: ZEND_LDAP method bind does not return Exception for credentials need one try on begin and catch on end function to return error


When I was testing my LDAP authentication method realized that the "bind ()" was not returning error message then added at the beginning and end of a "try""catch" with only "exception". Eg: try { . . } catch (Exception $ e) { echo $ e-> getMessage (); exit (); }

Note: Please try to fix this problem and return for the next version of Zend_Ldap.


This is the expected behavior of Zend_Ldap. If Zend_Ldap::bind() fails to bind, it throws an exception of type Zend_Ldap_Exception. The examples on the documentation pages don't do it, but you're Zend_Ldap code should look like this:

$ldap = new Zend_Ldap($options);
try {
    [...your LDAP actions here...]
} catch ( Zend_Ldap_Exception $e ) {
    [...handle case where LDAP can't connect...]

The unit tests in Zend_Ldap_BindTest do this as well. For example:

public function testEmptyOptionsBind()
    $ldap = new Zend_Ldap(array());
    try {
        $this->fail('Expected exception for empty options');
    } catch (Zend_Ldap_Exception $zle) {
        $this->assertContains('A host parameter is required', $zle->getMessage());

Well, this occurred when the LDAP server was not returned information or took too long to return, I believe that the library was a mistake to delay this because, simply stop the process of research and class error "LDAP exception" did not return anything but null.

My resolution of the problem was put in the search method from the library the output to 'catch (Exception) "and so get the exception error in communication.

As this error was not provided an instability in our LDAP servers do not believe I need to roast our brains to solving a complex.

I used google translate to translate this text, sorry.