use LDAP *ld; int err; ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &err); note that this list refers to the development of OpenLDAP software; your question addresses the usage of this software and should have been directed to openldap-software Pierangelo.