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

Re: Can I use LDAP_VALID within my app/library?

Khaled Blah writes:
> I would like to ask whether there is a way which allows me to use the
> macro "LDAP_VALID" in my own code. I would like to be able to check an
> LDAP* handle for its validity before I use that handle on any of the
> LDAP operation functions.

You could call something which uses LDAP_VALID() but does nothing
else.  For example:  (void) ldap_count_messages(ld, NULL).  But
that does assert(LDAP_VALID(ld)) which crashes if ld is invalid.

If you wish to use the macro directly:  Configure the
OpenLDAP source tree (to generate internal headers), then
#include <openldap source>/libraries/libldap/ldap-int.h.

Note that LDAP_VALID() is just a brief sanity check that the LDAP*
has been initialized properly and has not been destroyed:
  #define LDAP_VALID(ld)	( (ld)->ld_valid == LDAP_VALID_SESSION )