select u. grp_id, u.ana_id, u.user_id, u.user_pwd
from p18_user u
inner join p18_grp g
on u.grp_id = g.grp_id
where u.grp_id in (9, 6, 7, 11, 12, 13) -- utente registrato, studente, docente, soggetto esterno
and ((u.auth_pwd_location is null and g.auth_pwd_master_location = 1) or
u.auth_pwd_location = 1) -- gruppo con autenticazione DBMS
and exists (select 1
from p18_grp_client_type
where grp_id = g.grp_id
and client_type_cod = 'WEB') -- gruppo abilitato alle funzionalità web
and u.disable_flg = 0
and u.pwd_crypt_id is null -- pwd in chiaro