Yii,CUserIdentity,构造函数只有username,password

刚转到Yii上面来...

用LDAP来验证登陆...我没有用网上提供的ADLDAP这个类...因为那个看的很头疼,所以就用自己以前写的一个类..

定义LDAP的HOST NAME, PORT在config里面..

然后创建LoginForm的模型...调用component的UserIdentity...

UserIdentity是继承CUserIdentity..

在UserIdentity时候去调用LoginForm的username, password,domain...但是死活都调用不到domain,baidu一些,后面才发现CUserIdentity构造的时候是只有构造username跟password...

所以就没有传domain这个值过来...即使我在LoginForm调用$this->_identity = new UserIdentity($this->username, $this->password,$this->domain);也是一样的...

解决办法就是在UserIdentity写一个方法...

1   public function setUserDomain($userdomain) {
2         $this->userdomain = $userdomain;
3     }

然后在LoginForm里面在调用这个方法,把domain传给UserIdentity.

再去调用LDAP验证类...

posted on 2014-03-21 10:36  Kaka Zhou  阅读(331)  评论(0编辑  收藏  举报

导航