Revision #7 was created by Navarr on Jan 31, 2012, 5:57:06 PM.
fixed a typo, added "LDAP" tag
Tags
Authentication, LDAP
Content
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 ldapn 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:
```php
Yii::import('application.vendors.*');
require_once('Zend/Ldap.php');
```
Deletits very easy to implement LDAP in the stock UserIdentity class.
To do so, open your protected/components/UserIdentity.php and remove or comment out everythingthe code in the authenticate() function. Then add
return !$this->errorCode;
```
For this to work you need Exception.php, Ldap.phpOnce you have done this, open up your configs/main.php file, and andd the Ldap folder from the library folder of a Zend installation in the folder protected/vendors/Zend
following to the 'params' array at the bottom of the file:
```php
'ldap' => array(
'host' => 'hostname',
'ou' => 'organisational-unit', // such as "people" or "users"
'dc' => array('example','com'),
),
```
Replace the host with the hostname of the LDAP server, ou with the organisational unit you want to authenticate against (most LDAP servers use a broad terminology, such as "people"), and dc with the base DN. (For example array("ucla","edu") // ucla.edu)