How To Use Ldap For Authentication?

I would like to khow how to use ldap for authentication.

I have found link http://www.yiiframework.com/wiki/62/how-to-use-ldap-in-useridentity-for-authentication/#add-comment ask like this topic.

I have tried to insert the code is below to path protected/components/UserIdentity.php

$options = Yii::app()->params[‘ldap’];

$dc_string = “dc=” . implode(",dc=",$options[‘dc’]);

$connection = ldap_connect($options[‘host’]);

ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3);

ldap_set_option($connection, LDAP_OPT_REFERRALS, 0);

if($connection)

{

$bind = ldap_bind($connection, "uid={$this->username},ou={$options['ou']},{$dc_string}", $this->password);








if(!$bind) $this->errorCode = self::ERROR_PASSWORD_INVALID;


else $this->errorCode = self::ERROR_NONE;

}

return !$this->errorCode;

and I insert code is below to path: config/main.php

‘ldap’ => array(

                'host'      => 'xxx.xxx.xxx.xxx',


                'port'      => 389,


                'domain'    => 'xxxxxx',

),

then I run it.

the error show as below.

CWebApplication.ldap is not defined.

so I have try insert code is below instead before code in file main.php in path protected/config.

‘params’=>array(

	// this is used in contact page


	'adminEmail'=>'webmaster@example.com',


        'ldap'      => array(


                 'host'      => 'xxx.xxx.xxx.xxx',


                'port'      => 389,


                'domain'    => 'xxxxxx',

),

),

the web page is show display as follow:

The website cannot display the page.

and it is not show error message.

So in this case how can I do.

Thanks in advance.