src/model/UserDbLdap.php
public static function checkAllowedToLogin($userObjectDb) {
        if(static::getExtensionOptions('ENABLE_YII2_PROFILING') == true) {
            Yii::beginProfile('checkAllowedToLogin', static::YII2_PROFILE_NAME . 'checkAllowedToLogin');
        }        
        
        $userInstanceAfterLogin = null;
        
        if ($userObjectDb != null && 
            $userObjectDb->username != null &&
            $userObjectDb->getId() != null
            ) {        
            //Refresh account status on every request?
            if (static::getSyncOptions('ON_REQUEST_REFRESH_LDAP_ACCOUNT_STATUS', $userObjectDb->individualSyncOptions) == true) {
                $userObjectDb->updateAccountStatus();
            }

            //Login only possible if a role is assigned which matches the LOGIN_POSSIBLE_WITH_ROLE_ASSIGNED_MATCHING_REGEX regex
            if ($userObjectDb->status == static::STATUS_ENABLED &&
                static::getGroupAssigmentOptions('LOGIN_POSSIBLE_WITH_ROLE_ASSIGNED_MATCHING_REGEX',$userObjectDb->individualGroupAssignmentOptions) != null)
            {
                $rolesAssignedToUser = Yii::$app->authManager->getRolesByUser($userObjectDb->getId());

                foreach ($rolesAssignedToUser as $role) {
                    if(preg_match(static::getGroupAssigmentOptions('LOGIN_POSSIBLE_WITH_ROLE_ASSIGNED_MATCHING_REGEX',$userObjectDb->individualGroupAssignmentOptions),$role->name) == true) {
                        $userInstanceAfterLogin = $userObjectDb;
                        break;
                    }
                }
            }

            //Login possible if no role is assigned
            if ($userObjectDb->status == static::STATUS_ENABLED &&
                static::getGroupAssigmentOptions('LOGIN_POSSIBLE_WITH_ROLE_ASSIGNED_MATCHING_REGEX',$userObjectDb->individualGroupAssignmentOptions) == null)
            {
                $userInstanceAfterLogin = $userObjectDb;
            }
        }
        
        if(static::getExtensionOptions('ENABLE_YII2_PROFILING') == true) {
            Yii::endProfile('checkAllowedToLogin', static::YII2_PROFILE_NAME . 'checkAllowedToLogin');
        }        
        return $userInstanceAfterLogin;
    }
public static function checkAllowedToLogin($userObjectDb) {
        if(static::getExtensionOptions('ENABLE_YII2_PROFILING') == true) {
            Yii::beginProfile('checkAllowedToLogin', static::YII2_PROFILE_NAME . 'checkAllowedToLogin');
        }        
        
        $userInstanceAfterLogin = null;
        
        if ($userObjectDb != null && 
            $userObjectDb->username != null &&
            $userObjectDb->getId() != null
            ) {        
            //Refresh account status on every request?
            if (static::getSyncOptions('ON_REQUEST_REFRESH_LDAP_ACCOUNT_STATUS', $userObjectDb->individualSyncOptions) == true) {
                $userObjectDb->updateAccountStatus();
            }

            //Login only possible if a role is assigned which matches the LOGIN_POSSIBLE_WITH_ROLE_ASSIGNED_MATCHING_REGEX regex
            if ($userObjectDb->status == static::STATUS_ENABLED &&
                static::getGroupAssigmentOptions('LOGIN_POSSIBLE_WITH_ROLE_ASSIGNED_MATCHING_REGEX',$userObjectDb->individualGroupAssignmentOptions) != null)
            {
                $rolesAssignedToUser = Yii::$app->authManager->getRolesByUser($userObjectDb->getId());

                foreach ($rolesAssignedToUser as $role) {
                    if(preg_match(static::getGroupAssigmentOptions('LOGIN_POSSIBLE_WITH_ROLE_ASSIGNED_MATCHING_REGEX',$userObjectDb->individualGroupAssignmentOptions),$role->name) == true) {
                        $userInstanceAfterLogin = $userObjectDb;
                        break;
                    }
                }
            }

            //Login possible if no role is assigned
            if ($userObjectDb->status == static::STATUS_ENABLED &&
                static::getGroupAssigmentOptions('LOGIN_POSSIBLE_WITH_ROLE_ASSIGNED_MATCHING_REGEX',$userObjectDb->individualGroupAssignmentOptions) == null)
            {
                $userInstanceAfterLogin = $userObjectDb;
            }
        }
        
        if(static::getExtensionOptions('ENABLE_YII2_PROFILING') == true) {
            Yii::endProfile('checkAllowedToLogin', static::YII2_PROFILE_NAME . 'checkAllowedToLogin');
        }        
        return $userInstanceAfterLogin;
    }
Check if a [[Edvlerblog\Adldap2\model\UserDbLdap]] is allowed to login.
Two checks are done before a user object is returned.

1. Check if user is enabled
If [[ON_REQUEST_REFRESH_LDAP_ACCOUNT_STATUS]] option is true, the account status is
queryied ON EVERY REQUEST from LDAP and stored in database on login.

2. Check if the user has a role assigned which is allowed to login
See Parameter LOGIN_POSSIBLE_WITH_ROLE_ASSIGNED_MATCHING_REGEX

@param Edvlerblog\Adldap2\model\UserDbLdap $userObjectDb User object to validate.
@return Edvlerblog\Adldap2\model\UserDbLdap A User instance if user is valid. Otherwise NULL.