Establishing a session with an LDAP server is a four-step
process, although two of the steps are optional. The four steps
include:
Initialize a Session –
This step initializes the LDAP structure to
its default values. The LDAP structure is used to maintain session
state for the duration of the session. It includes options that
must be set to establish a connection to the server, such as
security options, LDAP version, timeout settings, and so on.
Set the Session
Options (optional) – In some cases, the default values for the
options are not required. If these default values are required, you
must set those options.
Connect to the
Server (optional) - Although it is not required that a client
call ldap_connect to establish a connection to the server,
it is a recommended programming practice.
Bind to the server
– Binding is the step where the LDAP server authenticates the
client and, if the client is successfully authenticated, allows the
client access to the LDAP server based on that client's privileges.
This can be an explicit bind using one of the binding functions, or
if you do not explicitly bind, the connection will implicitly run
as if you had bound as the anonymous user.