I am trying to write a function to determine if a specified user has a specific priv (ie INSERT) on an object. The caller will specify the object name, username, and priv to check. The problem I run into is that there are (at least) 5 ways a user can have rights to an object:
1. A direct grant on the object to the user.
2. A grant on the object to a role which the user has.
3. A super-priv like DBA or SELECT ANY TABLE, etc.
(these don't appear in DBA_TAB_PRIVS btw)
4. A grant to PUBLIC.
5. The specified username is the owner of the object.
I can use DBA_TAB_PRIVS, DBA_ROLE_PRIVS for 1,2, and 4. Item 5 is a simple IF statement, but #3 is the problem. Roles like SELECT ANY TABLE, INSERT ANY TABLE, and DBA show up in DBA_ROLE_PRIVS or DBA_SYS_PRIVS (user-role/priv), but I cannot find a connection from the super priv/role to the object anywhere in the data dictionary.
Other than hardcoding these "super privs", do anyone know a simple way answer the question "Does user X have privilege Y on object Z?" reliably? I have a feeling there is, but I'm just missing it.
Thanks in advance,
Rich ____________________________
Rich Tefft
PL/SQL Programmer
1. A direct grant on the object to the user.
2. A grant on the object to a role which the user has.
3. A super-priv like DBA or SELECT ANY TABLE, etc.
(these don't appear in DBA_TAB_PRIVS btw)
4. A grant to PUBLIC.
5. The specified username is the owner of the object.
I can use DBA_TAB_PRIVS, DBA_ROLE_PRIVS for 1,2, and 4. Item 5 is a simple IF statement, but #3 is the problem. Roles like SELECT ANY TABLE, INSERT ANY TABLE, and DBA show up in DBA_ROLE_PRIVS or DBA_SYS_PRIVS (user-role/priv), but I cannot find a connection from the super priv/role to the object anywhere in the data dictionary.
Other than hardcoding these "super privs", do anyone know a simple way answer the question "Does user X have privilege Y on object Z?" reliably? I have a feeling there is, but I'm just missing it.
Thanks in advance,
Rich ____________________________
Rich Tefft
PL/SQL Programmer