Hello to all,
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.
Regards,
Khaled
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 )
Whoops...
If you wish to use the macro directly: Configure the OpenLDAP source tree (to generate internal headers), then
#include "<openldap source>/include/portable.h"
#include <openldap source>/libraries/libldap/ldap-int.h.
At least that's what the OpenLDAP source files do.
I've searched for portable.h but couldn't find it in /usr/include or any of its subdirectories. I've also done "grep -r LDAP_VALID /usr/include/*" and that search did not return any results either. I will keep looking for it though and I would be grateful to anyone who could tell us more. I use Ubuntu 10.04 LTS.
Regards, Khaled
2011/10/24 Hallvard B Furuseth h.b.furuseth@usit.uio.no:
Whoops...
If you wish to use the macro directly: Configure the OpenLDAP source tree (to generate internal headers), then
#include "<openldap source>/include/portable.h"
#include <openldap source>/libraries/libldap/ldap-int.h.
At least that's what the OpenLDAP source files do.
-- Hallvard
Khaled Blah writes:
I've searched for portable.h but couldn't find it in /usr/include or any of its subdirectories. I've also done "grep -r LDAP_VALID /usr/include/*" and that search did not return any results either.
Quite so. ldap-int.h is in the openldap source tree. portable.h is generated there by configure. Neither should be installed anywhere:
#include "<openldap source>/include/portable.h"
#include <openldap source>/libraries/libldap/ldap-int.h.
On Oct 21, 2011, at 3:37 AM, Hallvard B Furuseth wrote:
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.
ldap_get_option(3).
-- Kurt
openldap-technical@openldap.org