【发布时间】:2012-03-28 08:30:25
【问题描述】:
我尝试编写一个 LdapAuthentication,我需要一些帮助。
首先我需要在 /app/Controller/ 中配置“$components” 组件/AppController.php
<?php
class AppController extends Controller {
var $components = array('Auth' => array(
'Ldap',
'authError' => 'Not allowed here',
'authenticate' => array('Form' => array(
'fields' => array(
'username' => 'username',
'password' => 'password',
'domain' => 'domain'
)
)
),
'authorize' => true,
), 'Session');
}
?>
然后我创建一个 LdapAuthorize.php http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#creating-custom-authorize-objects
<?php
App::uses('BaseAuthorize', 'Controller/Component/Auth');
class LdapAuthorize extends BaseAuthorize {
public function authorize($user, CakeRequest $request) {
echo "test";
}
}
?>
但是当我尝试登录时
if ($this->Auth->login()) {
return $this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('Username or password is incorrect'),
'default', array(), 'auth');
}
cakephp 没有使用我的授权功能。
我做错了什么?请帮忙。
【问题讨论】:
标签: php cakephp cakephp-2.0