[Date Prev][Date Next] [Chronological] [Thread] [Top]

Detecting errors in ldap_get_values



According to the C API draft, NULL is returned both when no values for
the attribute type are present in the entry and when some kind of error
happened.  I have seen code in sendmail 8.10.0 that tries to tell which
is it by calling ldap_get_option with LDAP_OPT_ERROR_NUMBER and checking
if the returned value is LDAP_SUCCESS.

However, it might not be because of an earlier error.  Apparently, the
code I am looking at is working correctly with the Netscape libraries,
but fails with the OpenLDAP development version.  I am about to fix this
problem, but I don't know what is the correct solution.

Should the hidden stored field that LDAP_OPT_ERROR_NUMBER manages be set
to LDAP_SUCCESS before calling ldap_get_values and then, if NULL is
returned, LDAP_OPT_ERROR_NUMBER will be LDAP_SUCCESS indicating no
values were retrieved and something else if an error happened?

Thanks in advance,

Julio