I'd like to check ldap_error only after a ldap_ function had failed.
However, ldap_next_entry yields FALSE if there are no more entries, even if no error occured.
But the manual suggests that it is OK to check errno even in this case, so I guess calling invokeLDAPMethod() will also work.
http://www.openldap.org/software/man.cgi?query=ldap_next_entry&sektion=3&manpath=OpenLDAP+2.4-Release