Howto use ldap in UserIdentity

You are viewing revision #1 of this wiki article.
This version may not be up to date with the latest version.
You may want to view the differences to the latest version.

next (#2) »

It took me a while to get ldap auth working with yii, so I write it down here, maybe it can be of some use.

Yii does not have a ldap class by itself, but you can extend it for example with Zend classes. To authenticate users at you page via ldap, change protected/components/UserIdentity.php in the following way:

On top of the file add:


Delete or comment out everything in the authenticate() function. Then add

$options = array(
        'host'              => '',
        'username'          => 'your_admin_users_username',
        'password'          => 'your_admin_users_password',
        'baseDn'            => 'your_base_dn',
        'useStartTls'        => true, # if you need startTls
$ldap = new Zend_Ldap($options);
        $ldap->bind("cn=".$this->username.",your_base_dn", $this->password);
catch (Exception $e){
return !$this->errorCode;

For this to work you need Exception.php, Ldap.php and the Ldap folder from the library folder of a Zend installation in the folder protected/vendors/Zend

11 0
Viewed: 54 846 times
Version: Unknown (update)
Category: Tutorials
Written by: BeerSerc
Last updated by: Navarr
Created on: Jan 26, 2010
Last updated: 4 years ago
Update Article


View all history

Related Articles