Yii Framework Forum: How To Use Ldap For Authentication? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Use Ldap For Authentication?

#1 User is offline   sit 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 19-June 13

Posted 19 June 2013 - 09:11 PM

I would like to khow how to use ldap for authentication.
I have found link http://www.yiiframew...on/#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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users