Method Protocols.LDAP.get_connection()


Method get_connection

object get_connection(string ldap_url, void|string binddn, void|string password, void|int version, void|SSL.Context ctx)

Description

Returns a client connection to the specified LDAP URL. If a bind DN is specified (either through a "bindname" extension in ldap_url or, if there isn't one, through binddn) then the connection will be bound using that DN and the optional password. If no bind DN is given then any connection is returned, regardless of the bind DN it is using.

version may be used to specify the required protocol version in the bind operation. If zero or left out, a bind attempt with the default version (currently 3) is done with a fallback to 2 if that fails. Also, a cached connection for any version might be returned if version isn't specified.

ctx may be specified to control SSL/TLS parameters to use with the "ldaps"-protocol. Note that changing this only affects new connections.

As opposed to creating an Protocols.LDAP.client instance directly, this function can return an already established connection for the same URL, provided connections are given back using return_connection when they aren't used anymore.

A client object with an error condition is returned if there's a bind error, e.g. invalid password.