Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User audit script how?

Status
Not open for further replies.

webfuture

MIS
Jan 17, 2003
65
CA
I would like a script to run under SQLplus to audit a user.

I am on oracle 9i.

The information I would like is:
1. default and temp table space
2. Roles
3. granted system privs
4. granted objects privs

Thanks,

Simon
 
Simon,

Here is a script that I wrote for you:
Code:
set pagesize 500
set linesize 200
set verify off
set feedback off
set heading on
accept usr prompt "Enter the Oracle User to Audit: "
prompt
col a heading 'Default Tablespace for "&usr":' format a30
select default_tablespace a from dba_users where username = upper('&usr');
col a heading '"&usr" is a member of|these Roles:' format a30
select granted_role a from dba_role_privs where grantee = upper('&usr');
col a heading '"&usr" has|these system privileges:' format a30
select privilege a from dba_sys_privs where grantee = upper('&usr');
prompt
prompt "&usr" has these object privileges:
prompt ====================================
col obj format a50
col priv format a15
break on obj
select privilege priv, owner||'.'||table_name obj
from dba_tab_privs where grantee = upper('&usr');
You will need to save the above code to a script (I called mine "Audit_User.sql"). Here is a sample invocation of the script:
Code:
SQL> @audit_user
Enter the Oracle User to Audit: dhunt


Default Tablespace for "dhunt"
------------------------------
DATA2

"dhunt" is a member of
these Roles:
------------------------------
DBA
CONNECT
RESOURCE
WHATEVER
DEV_USERS

"dhunt" has
these system privileges:
------------------------------
ALTER ANY TABLE
CREATE ANY TABLE
SELECT ANY TABLE
CREATE DATABASE LINK
UNLIMITED TABLESPACE

"dhunt" has these object privileges:
====================================

PRIV            OBJ
--------------- ---------------------
READ            SYS.FLATFILE_IO
WRITE
READ            SYS.MYFLATFILES
WRITE
Let us know if this is what you wanted.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
Providing remote Database Administration and support services

Do you use Oracle and live or work in Utah, USA?
Then click here to join Utah Oracle Users Group on Tek-Tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top