To connect to an LDAP server, you should use Net_LDAP's static connect() method. It takes one parameter, an array full of configuration options, and either returns a Net_LDAP object if connecting works, or a Net_LDAP_Error object in case of a failure.
The following table lists all configuration options. If the default value for an option fits your needs, you don't need add it to your configuration array.
Table 51-1. Possible configuration options
Name | Description | Default |
---|---|---|
host | LDAP server name to connect to. You can provide several hosts in an array in which case the hosts are tried from left to right. | localhost |
port | Port on the server | 389 |
version | LDAP version | 3 |
starttls | TLS is started after connecting | false |
binddn | The distinguished name to bind as (username) | (none) |
bindpw | Password for the binddn | (none) |
basedn | LDAP base name (root directory) | (none) |
options | Array of additional ldap options as key-value pairs | array() |
filter | Default search filter | (objectClass=*) |
scope | Default search scope, see Search | sub |
Example 51-1. Connecting to an LDAP server
|