Tuesday, July 3, 2007

How to Restrict Access of Some Users or Program in Oracle Prodcution Database

CREATE OR REPLACE TRIGGER programe_restrication

AFTER LOGON ON DATABASE

BEGIN

FOR x IN (SELECT username, program

FROM SYS.v_$session

WHERE audsid = USERENV ('sessionid'))

LOOP

IF LTRIM (RTRIM (x.username)) = 'AHMADBILAL'

AND LTRIM (RTRIM (x.program)) IN ('sqlplusw.exe', 'TOAD.exe')

THEN

raise_application_error

(-20999,

'Not authorized to use in the Production environment!'

);

END IF;

END LOOP;

END programe_restrication;

/