Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Trigger block logon - list users

User_CYMGWJan 14 2016 — edited Jan 19 2016

Hi.

Can help me with this doubt, he missed working with development to have better ideas.

Next I'm trying to create a trigger to lock the operating system user access with a username database. This is quiet, however, I wish these operating system users were registered on a table and during execution of the trigger were performed to validate these logins:

CREATE OR REPLACE TRIGGER SYS.BLOCK_USER

AFTER LOGON ON DATABASE

  DECLARE

  v_prog sys.v_$session.program%TYPE;

  v_username sys.v_$session.username%TYPE;

  v_osuser sys.v_$session.osuser%TYPE;

  v_sid sys.v_$session.sid%TYPE;

  v_serial sys.v_$session.sid%TYPE;

  --v_inst_id sys.v_$session.sid%TYPE;

  BEGIN

  SELECT program, username, osuser, sid, serial#

  INTO v_prog, v_username, v_osuser, v_sid, v_serial

  FROM sys.v_$session

  WHERE sid = USERENV('SID')

  AND audsid != 0 -- Não verifica conexões do SYS

  AND rownum = 1; -- Parallel processes will have the same AUDSID's

  IF UPPER(v_osuser) not in ('BR3AMR','BR3CAM8')

  THEN

  IF (UPPER(v_username) = 'ADMRMS')

  THEN

 

  RAISE_APPLICATION_ERROR(-20000, 'Block Access! ('||v_osuser||' - '||v_username||' -  '||v_prog||')');

  END IF;

  END IF;

  EXCEPTION

  WHEN NO_DATA_FOUND THEN NULL;

  END;

/

Hi.

Can help me with this doubt, he missed working with development to have better ideas.

Next I'm trying to create a trigger to lock the operating system user access with a username database. This is quiet, however, I wish these operating system users were registered on a table and during execution of the trigger were performed to validate these logins:

As above code, the line "IF UPPER (v_osuser) not in", the user should not be fixed but the trigger on a table, in case new users entering the company, there is no need for maintaining the trigger.

Is there a solution for this?

hugs!!

This post has been answered by BrunoVroman on Jan 15 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 16 2016
Added on Jan 14 2016
17 comments
3,710 views