ldap_search() and ldap_result() returns -1 in case of error, but how do I know what exactly the error was? Internally it uses ld->ld_errno, but LDAP struct isn't accessible externally. I didn't see any function either for accessing it, except for ldap_perror() but I don't want to print it to stderr.