Closing a Connection

When an LDAP client has finished communicating with a server, and all necessary memory cleanup is complete, call ldap_unbind or ldap_unbind_s to unbind from the directory, close the connection, and release the session handle. Call this function when you have finished with a connection, even if you have not explicitly called a bind function to open the connection.

Both ldap_unbind and ldap_unbind_s work synchronously. There is no server response to an unbind operation. Ensure that you do not inadvertently call either unbind function more than one time on a session handle; doing so can free resources that you did not intend to release.