Поделиться через


Establishing an LDAP Session

Establish an LDAP session before performing LDAP operations on an LDAP server.

The steps required to establish an LDAP server session are as follows. Steps 2 and 3 are optional.

To establish an LDAP session

  1. Initialize a Session — Sets the default session option settings in the LDAP structure. The LDAP session state is stored in the LDAP structure. The session options can be read or set prior to binding.
  2. Set the Session Options (optional) — Reads existing session options and sets new session option values, as required. In some cases, the default values for the session options are acceptable. However, if session option changes are required, set those options at this point.
  3. Connect to the Server (optional) — Establishes an LDAP connection to the LDAP server. It is not required that a client call ldap_connect to establish a server connection. Binding will establish the server connection if it does not exist. However, using ldap_connect is a recommended programming practice for detecting connectivity problems.
  4. Bind to the server — The LDAP server authenticates the client. If the client successfully authenticates, then client can access to the LDAP server, based on the privileges of that client. This can be an explicit bind using one of the binding functions. This can also be an implicit bind as an anonymous user.

The following are examples of how to establish an LDAP session: