YII LDAP連接我的新YII幀工作我想創建用於用戶認證 我採取創建下面的步驟的LDAP配置,但它eerro拋出如下用於用戶認證
包括(控制器。 PHP)[]:未能打開流:沒有這樣的文件或目錄
C:\ XAMPP \ htdocs中\ yiif \框架\ YiiBase.php(418)
步驟: 1.我有在C:\ xampp \ htdocs \ seed2 \ protecte中包含以下ldaprecord/ 擴展名d \擴展\ ldaprecord 2.我已經包括如下代碼中的配置/ main.php
`'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
'ldap'=>array(
'class' => 'ext.ldaprecord.LdapComponent',
'server' => 'ldap://192.168.x.xxxx',
'port' => 389,
//'bind_rdn' => 'cn=suren diran,cn=Users,dc=xxxx,dc=demo,dc=com',
//'bind_pwd' => '[email protected]',
'base_dn' => 'dc=rsales,dc=demo,dc=com'),);
'params'=>array(
// this is used in contact page
'adminEmail'=>'[email protected]',
),
'ldap'=>array(
'class' => 'ext.ldaprecord.LdapComponent',
'server' => 'ldap://192.168.x.xxx',
'port' => 389,
//'bind_rdn' => 'cn=xxxx xxxx,cn=Users,dc=xxxx,dc=demo,dc=com',
//'bind_pwd' => '[email protected]',
'base_dn' => 'dc=xxxxx,dc=demo,dc=com'),
);`
包括在的index.php
$config=dirname(__FILE__).'/protected/extensions/ldaprecord/CLdapRecord.php';
和我此行已將用戶身份驗證功能更改爲
` public function authenticate() { $ username = $ this-> username; $ password = $ this-> password; $ dname ='xxxxxxx'; $ options ['host'] ='ldap://192.168.x.xxx'; $ options ['port'] = 389; $ ldap_username =「CN =」。$ username。「,CN = Users,DC = xxxx,DC = demo,DC = com」;
$options = Yii::app()->params['ldap'];
print_r($options);
$connection = ldap_connect($options['host'], $options['port']);
//print_r($connection);
ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($connection, LDAP_OPT_REFERRALS, 0);
if($connection)
{
echo "success";
//exit;
try
{
//echo $connection.$ldap_username.$this->password;
//print_r(ldap_bind($connection,$dname."\\". $ldap_username, $password));
//exit;
@$bind = ldap_bind($connection,$dname."\\". $ldap_username, $password);
print_r(@$bind);
if(@$bind)
{
echo "successfully logedin";
}
}
catch (Exception $e){
echo $e->getMessage();
}
if(!$bind) $this->errorCode = self::ERROR_PASSWORD_INVALID;
else $this->errorCode = self::ERROR_NONE;
}
return !$this->errorCode;
};`
我stucked這裏任何一個可以幫助我HW解決這個問題。請幫助我,在此先感謝..........
Controller.php這樣的文件是存在於受保護/組件 甚至我檢查它是否已經包括在主.PHP
'import'=>array(
'application.models.*',
'application.components.*',
'ext.ldaprecord.*',
),
如果刪除下面的行下面的錯誤將圖示 代碼:
$config=dirname(__FILE__).'/protected/extensions/ldaprecord/CLdapRecord.php'
錯誤: 屬性「CWebApplication.ldap」未定義。
是我使用的擴展只有你給的鏈接上面([http://www.yiiframework.com/extension/ldaprecord/]),如果你有任何其他的擴展名,請你可以提供該鏈接,什麼步驟需要採取爲實現.........謝謝提前..........
HIIIIII
我在做PARAMS現在的錯誤,我已經改變如下圖,我刪除了
$config=dirname(__FILE__).'/protected/extensions/ldaprecord/CLdapRecord.php';
它沒有引發任何錯誤。
我包括我的主要。下面的PHP全碼:
<?php
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'xxxxxx',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
//ldap config added code
'ext.ldaprecord.*',
),
'defaultController' => 'site/login',
'modules'=>array(
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'pass',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to enable URLs in path-format
/*'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),*/
/*'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),*/
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=xxxxx',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'tablePrefix' => '',
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
'ldap'=>array(
'class' => 'ext.ldaprecord.LdapComponent',
'server' => 'ldap://192.168.x.xxx',
'port' => 389,
//'bind_rdn' => 'cn=suren diran,cn=Users,dc=xxxxxx,dc=demo,dc=com',
//'bind_pwd' => '[email protected]',
'base_dn' => 'dc=xxxxx,dc=demo,dc=com'),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'[email protected]',
'ldap'=>array(
'class' => 'ext.ldaprecord.LdapComponent',
'server' => 'ldap://192.168.x.xxx',
'port' => 389,
//'bind_rdn' => 'cn=suren diran,cn=Users,dc=xxxxx,dc=demo,dc=com',
//'bind_pwd' => '[email protected]',
'base_dn' => 'dc=xxxx,dc=demo,dc=com'),
),
);
我包括我下面的UserIdentity功能:
<?php
public function authenticate()
{
$options = Yii::app()->params['ldap'];
//print_r($options);
$connection = ldap_connect($options['host'], $options['port']);
ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($connection, LDAP_OPT_REFERRALS, 0);
if($connection)
{
// try
// {
//echo $options['domain']."\\".$this->username. $this->password;
//exit;
$ldap_username = "CN=".$this->username.",CN=xxxx,DC=xxxx,DC=demo,DC=com";
$ldap_password=$this->password;
echo $connection.$ldap_username.$ldap_password;
//$bind=ldap_bind($connection, $ldap_username, $ldap_password)
//exit;
//print_r(ldap_bind($connection,$ldap_username,$ldap_password));
$bind = @ldap_bind($connection,$ldap_username, $ldap_password);
print_r($bind);
//exit;
//@$bind = ldap_bind($connection,$ldap_username, $ldap_password);
// [email protected]$bind;
//print_r($abc);
//exit;
/*}
catch (Exception $e){
echo $e->getMessage();
}*/
if(!$bind) $this->errorCode = self::ERROR_PASSWORD_INVALID;
else $this->errorCode = self::ERROR_NONE;
}
return !$this->errorCode;
}
但在上述之一的ldap_bind不工作u能在這個幫助........ 請幫助我,我如何克服這個.........非常感謝.....
是我使用的擴展只其中U上面給出的鏈接,如果u有任何其他分機請ü可以提供鏈接,哪些步驟需要採取爲實現.........謝謝提前.......... – DILLI
不顛簸你的配置是一個開始。並檢查配置中括號的嵌套層次。有些東西正在將'ldap'部分從'components'-stanza中移出。 – DaSourcerer
'分量'=>數組( '的ErrorHandler'=>數組( 'errorAction'=> '位點/錯誤', ) \t \t '登錄'=>數組( \t \t \t '類'=> 'CLogRouter', \t \t \t '路線'=>數組( \t \t \t \t陣列( \t \t \t \t \t '類'=> 'CFileLogRoute', \t \t \t \t \t '平'=> '錯誤,警告', \t \t \t \t) \t \t \t \t \t \t \t \t \t \t) \t \t) \t \t \t \t \t \t \t \t'ldap'=> array( 'class'=>'ext.ldaprecord.LdapComponent', 'server'=>'ldap://192.168.x。xxxx', 'port'=> 389, //'bind_rdn'=>'cn = xxxx xxxx,cn = Users,dc = xxxx,dc = demo,dc = com', //'bind_pwd'=> '通過@ 123', 'base_dn'=> 'DC = XXXXX,DC =演示,DC = COM'), \t \t \t \t \t \t \t \t \t), – DILLI