NAME |LIBRARY |SYNOPSIS |DESCRIPTION |ERRORS |SEE ALSO |ACKNOWLEDGEMENTS |COLOPHON | |
LDAP_OPEN(3) Library Functions ManualLDAP_OPEN(3)ldap_dup, ldap_destroy, - Duplicate and destroy LDAP session handles
OpenLDAP LDAP (libldap, -lldap)
#include <ldap.h>LDAP *ldap_dup(LDAP *old);int ldap_destroy(LDAP *old);
ldap_dup()duplicates an existing LDAP (LDAP *) session handle. The new session handle may be used concurrently with the original session handle. In a threaded environment, different threads may execute concurrent requests on the same connection/session without fear of contamination. Each session handle manages its own private error results.ldap_destroy()destroys an existing session handle. Theldap_dup()andldap_destroy()functions are used in conjunction with a "thread safe" version oflibldapto enable operation thread safe API calls, so that a single session may be simultaneously used across multiple threads with consistent error handling. When a session is created through the use of one of the session creation functions includingldap_open(3),ldap_init(3),ldap_initialize(3) orldap_init_fd(3) anLDAP *session handle is returned to the application. The session handle may be shared amongst threads, however the error codes are unique to a session handle. Multiple threads performing different operations using the same session handle will result in inconsistent error codes and return values. To prevent this confusion,ldap_dup()is used duplicate an existing session handle so that multiple threads can share the session, and maintain consistent error information and results. The message queues for a session are shared between sibling session handles. Results of operations on a sibling session handles are accessible to all the sibling session handles. Applications desiring results associated with a specific operation should provide the appropriate msgid toldap_result(). Applications should avoid callingldap_result()withLDAP_RES_ANY as that may "steal" and return results in the calling thread that another operation in a different thread, using a different session handle, may require to complete. Whenldap_unbind()is called on a session handle with siblings, all the siblings become invalid. Siblings must be destroyed usingldap_destroy(). Session handle resources associated with the original (LDAP *) will be freed when the last session handle is destroyed or whenldap_unbind()is called, if no other session handles currently exist.
If an error occurs,ldap_dup()will return NULL anderrno should be set appropriately.ldap_destroy()will directly return the LDAP code associated to the error (orLDAP_SUCCESS in case of success);errno should be set as well whenever appropriate.
ldap_open(3),ldap_init(3),ldap_initialize(3),ldap_init_fd(3),errno(3)
This work is based on the previously proposedLDAP C APIConcurrency Extensionsdraft(draft-zeilenga-ldap-c-api- concurrency-00.txt)effort.OpenLDAP Softwareis developed and maintained by The OpenLDAP Project <http://www.openldap.org/>.OpenLDAP Softwareis derived from the University of Michigan LDAP 3.3 Release.
This page is part of theOpenLDAP (an open source implementation of the Lightweight Directory Access Protocol) project. Information about the project can be found at ⟨http://www.openldap.org/⟩. If you have a bug report for this manual page, see ⟨http://www.openldap.org/its/⟩. This page was obtained from the project's upstream Git repository ⟨https://git.openldap.org/openldap/openldap.git⟩ on 2025-08-11. (At that time, the date of the most recent commit that was found in the repository was 2025-08-05.) If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up-to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.orgOpenLDAP LDVERSION RELEASEDATELDAP_OPEN(3)HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |