LDAP session
It is necessary to create an LDAP session (Smalltalk class LdapSession) with the LDAP server before performing any operations on the server's data.
1. Create and initialize a new instance of LdapSession.
2. Connect it to your server.
3. Set the LDAP protocol version to 3; version 2 is obsolete and should not be used.
4. Bind the LDAP session to the server; bind is equivalent to logon.
See EsLdapExamples class>> newLdapSessionForExample in the configuration map ENVY/Image LDAP Examples. In this example the hostname is 127.0.0.1 (aka localhost) and the port is 10389. This corresponds to the way the Apache Directory Studio was set up for this example.
Among other messages, LdapSession understands:
getFirstRootEntry –
Gets the first root entry. (See EsLdapExamples class>> exampleGetFirstRootEntry.)
getAllRootEntries –
Gets all the first root entries. (See EsLdapExamples class>> exampleGetAllRootEntries.)
unbind –
Frees all resources associated with an LDAP session.
Note:
Best practice is to end the session once the data on the LDAP server is no longer required.
Defining session callback options
The LdapSession object already allowed setting various options using values such as integers or strings. However, some options allow the execution of a callback function that is evaluated in the context of the LDAP library.
As of VAST 14.0.0, we enable the ability to pass a callback as an option, useful for cases like client or server LDAPS certificate resolution.
The way to define such callbacks is by means of using an instance of EsEntryPoint as follows:
clientCertCallback :=
EsEntryPoint
receiver: [:ldap :trustedCerts :context | false ]
selector: #value:value:value:
callingConvention: 'c'
arrayBased: false
parameterTypes: #(pointer pointer pointer)
returnType: #bool.
ldapSession ldapSetOption: LdapConstants::LDAP_OPT_CLIENT_CERTIFICATE pointer: clientCertCallback address.
Note
EsEntryPoint is an external object and must be freed when the session ends, otherwise there may be a memory leak caused by unreferenced callbacks residing in the memory heap.
Last modified date: 02/24/2025