CWebUser without User model ?

Can we extend CWebUser without the present of User model class? Currently I do not define User model class, instead I’m using other class name ( and table ) to define user class ( LdapUser ) I tried to create this class :

class WebUser extends CWebUser {


	private $_model;


	function isAdmin() {

		$user = $this->loadUser(Yii::app()->user->id);

		return intval($user->role_id)==1;



	protected loadUser($id){



				$this->_model = Ldapuser::model()->findByAttributes(array('user_id'=>$id))



		return $this->_model;



and configuration file :




                // enable cookie-based authentication




But Im getting white screen with these option.

Please help :)

If you generated the application, you should take a look at WebRoot/protected/components/UserIdentity.php, that is where authentication is configured.

"CWebUser should be used together with an identity which implements the actual authentication algorithm." - CWebUser


function authenticate() {

    $user = Ldapuser::model()->findByAttributes(array('user_id'=>$id)); // why not findByPk($id) ?

    if ($user === null) {

        $this->errorCode = self::ERROR_USERNAME_INVALID;


    else {

        if($user->password!==$user->encrypt($this->password)) {

            $this->errorCode self::ERROR_PASSWORD_INVALID;


        else {

            $this->_id = $user->id




    return !$this->errorCode;


public function getId() {

    return $this->_id;


If you get white screen it means that you have some syintax error that is not displayed.

Put this in your index.php:



in order to display all errors.

Thanks zaccaria, it was indeed a syntax error. Now I get the custom WebUser class running smoothly. :slight_smile: