Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to query the permissions on an Oracle directory?

I have a directory in all_directories, but I need to find out what permissions are associated with it, i.e. what has been granted on it?

like image 774
Cade Roux Avatar asked Jun 17 '11 18:06

Cade Roux


People also ask

Where can I find user privileges in Oracle?

Querying DBA/USER Privilege Views A database administrator (DBA) for Oracle can simply execute a query to view the rows in DBA_SYS_PRIVS , DBA_TAB_PRIVS , and DBA_ROLE_PRIVS to retrieve information about user privileges related to the system , tables , and roles , respectively.

How do I grant privileges to a directory in Oracle?

After you create a directory alias, grant users and groups access rights to the files contained in that directory, using the following PL/SQL syntax: GRANT permission ON DIRECTORY alias TO {user | role | PUBLIC};

How do I view permissions in SQL Developer?

How do I view privileges in Oracle SQL Developer? To check the roles granted to a user: SELECT * FROM DBA_ROLE_PRIVS WHERE GRANTEE = 'USERNAME'; Permissions already have: SELECT * FROM DBA_TAB_PRIVS WHERE GRANTEE = 'USERNAME'; System privileges granted: SELECT * FROM DBA_SYS_PRIVS WHERE GRANTEE = 'USERNAME';


3 Answers

This should give you the roles, users and permissions granted on a directory:

SELECT * 
  FROM all_tab_privs 
 WHERE table_name = 'your_directory';  --> needs to be upper case

And yes, it IS in the all_TAB_privs view ;-) A better name for that view would be something like "ALL_OBJECT_PRIVS", since it also includes PL/SQL objects and their execute permissions as well.

like image 199
DCookie Avatar answered Oct 07 '22 11:10

DCookie


You can see all the privileges for all directories wit the following

SELECT *
from all_tab_privs
where table_name in
  (select directory_name 
   from dba_directories);

The following gives you the sql statements to grant the privileges should you need to backup what you've done or something

select 'Grant '||privilege||' on directory '||table_schema||'.'||table_name||' to '||grantee 
from all_tab_privs 
where table_name in (select directory_name from dba_directories);
like image 37
Alex Porteous Avatar answered Oct 07 '22 12:10

Alex Porteous


Wasn't sure if you meant which Oracle users can read\write with the directory or the correlation of the permissions between Oracle Directory Object and the underlying Operating System Directory.

As DCookie has covered the Oracle side of the fence, the following is taken from the Oracle documentation found here.

Privileges granted for the directory are created independently of the permissions defined for the operating system directory, and the two may or may not correspond exactly. For example, an error occurs if sample user hr is granted READ privilege on the directory object but the corresponding operating system directory does not have READ permission defined for Oracle Database processes.

like image 20
Ian Carpenter Avatar answered Oct 07 '22 12:10

Ian Carpenter