The LDAP authentication driver allows you to authenticate users against
entries in an LDAP directory (see Chapter 12, LDAP module).
The attribute used as the identifier is the common name (cn).
This driver works similarly to the database table driver.
The only difference is that you only have to pass the weeLDAP object and the base dn where the users are stored.
<?php // This could be data sent by a form, for example $aTest = array( 'identifier' => 'Luke Skywalker', 'password' => 'mypassword42', ); // Create the authentication driver $oAuth = new weeAuthLDAP(array( 'ldap' => $oLDAP, 'base_dn' => 'ou=people, dc=example, dc=com', )); try { $oEntry = $oAuth->authenticate($aTest); // Authentication succeeded } catch (AuthenticationException $e) { // Authentication failed }
weeAuthLDAP::authenticate checks if the common name Luke Skywalker
exists in the DN ou=people, dc=example, dc=com and that the password specified match
the password of the entry cn=Luke Skywalker, ou=people, dc=example, dc=com.
If authentication fails, an AuthenticationException is thrown.