We're using Zend_Ldap to authenticate users using LDAP on a project. One of the clients we setup was having a problem getting the connection to work where our web server would connect to their LDAP server and then it would pause for 30 minutes before returning an error. To debug this you set the following option:

ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);

Then you would just call ldap_error to get the debug information. We didn't want random bugs listed on our server but it turns out that with this set the debug settings are logged to the php.log.