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

How to properly initialize the LDAP client library

I'm using both libldap and libsasl2 in my application on Mac OS X.  libldap itself uses libsasl2 internally on that platform, and it changes some of the libsasl2 globals (namely the mutex functions) during its initialization.  My app uses libldap only in response to user actions, so libldap initialization happens at a fairly random time.  This means the libsasl2 globals end up changing on me after I've been using libsasl2 for awhile in my app's lifecycle, and I end up getting random crashes because the mutex functions are all different from when I initially created the sasl client connection.

So, my solution to this was to initialize libldap myself on app launch so that it can set up the libsasl2 environment as it wants to.  I looked at the manual page for ldap(3) and ldap_initialize(3), and they seemed to suggest that I should use ldap_get_option to initialize OpenLDAP.  Which option should I ask for though?  I tried LDAP_OPT_API_INFO, but that ends up doing a DNS query which can really balloon my launch time depending on my network configuration. Is there a better option I could do that basically does nothing but initialize a few innocuous OpenLDAP globals without doing a significant amount of work?