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

Issue Type: Bug Created: 2011-04-12T19:37:05.000+0000 Last Updated: 2011-04-29T17:55:06.000+0000 Status: Resolved Fix version(s): Reporter: Andre Guariento (fominomato) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Ldap

  • Action_Helper
  • Authentication
  • LDAP

Related issues: Attachments:


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.


Posted by Adam Lundrigan (adamlundrigan) on 2011-04-29T17:09:35.000+0000

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:

<pre class="highlight">
$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:

<pre class="highlight">
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());

Posted by Andre Guariento (fominomato) on 2011-04-29T17:55:06.000+0000

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.

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.