public function validate($data) {

        if (get_config('auth_ldap', 'ntlmsso_type') === 'ntlm') {
            $format = trim($data);
            if (!empty($format) && !preg_match('/%username%/i', $format)) {
                return get_string('auth_ntlmsso_missing_username', 'auth_ldap');
            }
        }

        return parent::validate($data);
    }