Colega , ROLE é um conjunto de privs, então na minha prática diário 
privs vão pra usuários, não pra outros conjuntos (roles), imho isso é 
uma complicação , então fica por sua conta a verif, ** mas ** no meu 
teste o script de privilégios que já passei pra lista em msgs 
anteriores funcionou nesses casos, exemplo :

==> primeiro crio um user qquer, e dou uns pribs pra ele :

[EMAIL PROTECTED]:SQL>create user lixo identified by lixo;

Usuário criado.

[EMAIL PROTECTED]:SQL>grant create session, create table to lixo;

Concessão bem-sucedida.

==> consultando :

[EMAIL PROTECTED]:SQL>@privs_by_user
Gravou file D:\dba_scripts\sqlplus_settings.sql
Enter Username : lixo
Roles granted to user

não há linhas selecionadas

Table Privileges granted to a user through roles

não há linhas selecionadas

System Privileges assigned to a user through roles

não há linhas selecionadas

Table privileges assigned directly to a user

não há linhas selecionadas

System privileges assigned directly to a user

PRIVILEGE                         ADM
--------------------------------- ---
CREATE TABLE                      NO
CREATE SESSION                    NO

==> agora dou uma role pra ele :

[EMAIL PROTECTED]:SQL>grant ROL_QUERY_DML to lixo;

Concessão bem-sucedida.

==> consulto de novo, VEJA que o script já nos diz que ele recebeu a 
role, E quais privs vieram dela :

[EMAIL PROTECTED]:SQL>@privs_by_user
Gravou file D:\dba_scripts\sqlplus_settings.sql
Enter Username : lixo
Roles granted to user

GRANTED_ROLE         ADM DEF
-------------------- --- ---
ROL_QUERY_DML        NO  YES

Table Privileges granted to a user through roles

GRANTED_ROLE  OWNER TABLE_NAME PRIVILEGE
------------- ----- ---------- ---------
ROL_QUERY_DML SCOTT DEPT       DELETE
ROL_QUERY_DML SCOTT DEPT       INSERT
ROL_QUERY_DML SCOTT DEPT       SELECT
ROL_QUERY_DML SCOTT DEPT       UPDATE

System Privileges assigned to a user through roles

não há linhas selecionadas

Table privileges assigned directly to a user

não há linhas selecionadas

System privileges assigned directly to a user

PRIVILEGE                         ADM
--------------------------------- ---
CREATE TABLE                      NO
CREATE SESSION                    NO

==> agora vou dar privs de uma role para essa role que o cara já tem :

[EMAIL PROTECTED]:SQL>grant GATHER_SYSTEM_STATISTICS to ROL_QUERY_DML;

Concessão bem-sucedida.

==> veja lá que vai aparecer normalmente os privs de AMBAS as roles, 
mas na seçao "roles recebidas" só vai estar a role que ele recebeu 
diretamente (a ROL_QUERY_DML), MOSTRANDO que os privs da(s) outra 
role (a GATHER_SYSTEM_STATISTICS) ele herdou :

[EMAIL PROTECTED]:SQL>@privs_by_user
Gravou file D:\dba_scripts\sqlplus_settings.sql
Enter Username : lixo
Roles granted to user

GRANTED_ROLE         ADM DEF
-------------------- --- ---
ROL_QUERY_DML        NO  YES

Table Privileges granted to a user through roles

GRANTED_ROLE         OWNER TABLE_NAME PRIVILEGE
-------------------- ----- ---------- ---------
GATHER_SYSTEM_STATIS SYS   AUX_STATS$ DELETE
TICS

GATHER_SYSTEM_STATIS SYS   AUX_STATS$ INSERT
TICS

GATHER_SYSTEM_STATIS SYS   AUX_STATS$ SELECT
TICS

GATHER_SYSTEM_STATIS SYS   AUX_STATS$ UPDATE
TICS

ROL_QUERY_DML        SCOTT DEPT       DELETE
ROL_QUERY_DML        SCOTT DEPT       INSERT
ROL_QUERY_DML        SCOTT DEPT       SELECT
ROL_QUERY_DML        SCOTT DEPT       UPDATE

8 linhas selecionadas.

System Privileges assigned to a user through roles

não há linhas selecionadas

Table privileges assigned directly to a user

não há linhas selecionadas

System privileges assigned directly to a user

PRIVILEGE                         ADM
--------------------------------- ---
CREATE TABLE                      NO
CREATE SESSION                    NO

[EMAIL PROTECTED]:SQL>

==> o script :

set echo off
set verify off
set pages 200
col granted_role form a20
col owner form a15
col table_name form a33
col privilege form a33
ACCEPT username  prompt 'Enter Username : '
PROMPT Roles granted to user
SELECT granted_role,admin_option,default_role
FROM dba_role_privs
WHERE grantee=UPPER('&username')
ORDER BY 1;
PROMPT Table Privileges granted to a user through roles
SELECT granted_role, owner, table_name, privilege
FROM ( SELECT granted_role
    FROM dba_role_privs WHERE grantee=UPPER('&username')
       UNION
       SELECT granted_role
    FROM role_role_privs
    WHERE role in (SELECT granted_role
             FROM dba_role_privs WHERE grantee=UPPER('&username')
            )
   ) roles, dba_tab_privs
WHERE granted_role=grantee
ORder by 1,2,3,4;
PROMPT System Privileges assigned to a user through roles
SELECT granted_role, privilege
FROM ( SELECT granted_role
    FROM dba_role_privs WHERE grantee=UPPER('&username')
       UNION
       SELECT granted_role
    FROM role_role_privs
    WHERE role in (SELECT granted_role
             FROM dba_role_privs WHERE grantee=UPPER('&username')
            )
   ) roles, dba_sys_privs
WHERE granted_role=grantee
 ORDER BY 1,2;
PROMPT Table privileges assigned directly to a user
SELECT owner, table_name, privilege
FROM dba_tab_privs
WHERE grantee=UPPER('&username')
ORDER BY 1,2,3;
PROMPT System privileges assigned directly to a user
SELECT privilege, admin_option
FROM  dba_sys_privs
WHERE grantee=UPPER('&username');
undefine username
-- fim do script

[]s

  Chiappa

--- Em oracle_br@yahoogrupos.com.br, "Thiago Delfim" <[EMAIL PROTECTED]> 
escreveu
>
> Pessoal,
> 
> eu estou precisando de uma query (ou procedure) que liste, por 
exemplo,
> todos os usuários que possuem privilégio "CREATE SESSION".
> Eu usei algumas (que coloco abaixo), mas nenhuma delas listam todos 
os
> usuários. Ainda não resolvi o problema quando o privilégio é dado a 
uma
> role, essa role para outra role, e essa role para um usuário.
> Alguém conhece uma query ou procedure que rode em Oracle 8, 9 e 10 
e me
> traga isso?
> - Quais os usuários que possuem privilégio de "CREATE SESSION" (ou 
DROP,
> ALTER SESSION, etc...)
> - Quais os usuários que possuem a role DBA (ou DELETE_CATALOG_ROLE, 
etc...)
> 
> Essa query só funciona no 9i, e para role parece que traz tudo:
> SELECT grantee, granted_role FROM dba_role_privs
> START WITH granted_role='DBA'
> CONNECT BY PRIOR grantee = granted_role;
> 
> Essa outra funciona no 8, 9 e 10, mas só verifica dois níveis:
> SELECT a.grantee, a.granted_role
> FROM dba_role_privs a, dba_role_privs b
> WHERE a.granted_role = b.grantee
> AND b.granted_role='DBA'
> UNION
> SELECT grantee, granted_role
> FROM dba_role_privs
> WHERE granted_role='DBA'
> ORDER BY 2;
> 
> Essa funciona em todas as versões, mas também não varre todos os 
níveis:
> select
>    rp.GRANTEE,GRANTED_ROLE,rp.ADMIN_OPTION,DEFAULT_ROLE,PRIVILEGE
> from
> dba_role_privs rp, dba_sys_privs sp
> where    rp.GRANTEE = sp.GRANTEE
> and      rp.GRANTEE not in ('SYS','SYSTEM', 'DBA')
> and      privilege = 'CREATE SESSION'
> order by rp.GRANTEE, GRANTED_ROLE, PRIVILEGE;
> 
> 
> 
> Alguém pode me ajudar?
> 
> 
> -- 
> Thiago Delfim
> Oracle & SQL Server Database Administrator
> Oracle 9i Database Certified Associate
> IBM IT Delivery
> [EMAIL PROTECTED] (MSN)
> Campinas/SP
> (19) 9111-1439
> 
> 
> [As partes desta mensagem que não continham texto foram removidas]
>


Responder a