Oct 15, 2013

Block sessions which are connected through "Toad" or "plsqldeveloper" in production database

-- Restrict / block sessions which are connected through third party tools in prod database
-- Applicable to any oracle version

rem -----------------------------------------------------------------------
rem Filename:   NoTools.sql
rem Purpose:    Block developers from using TOAD or PLSQL Developer and other tools on production databases.
rem Date:       15-OCT-2013
rem Author:     Gouranga Mohapatra
rem -----------------------------------------------------------------------

CONNECT / AS SYSDBA;

CREATE OR REPLACE TRIGGER t_block_tools_from_prod
  AFTER LOGON ON DATABASE
DECLARE
  v_prog sys.v_$session.program%TYPE;
BEGIN
  SELECT program INTO v_prog
    FROM sys.v_$session
  WHERE  audsid = USERENV('SESSIONID')
    AND  audsid != 0  -- Don't Check SYS Connections
    AND  rownum = 1;  -- Parallel processes will have the same AUDSID's

  IF UPPER(v_prog) LIKE '%TOAD%' OR UPPER(v_prog) LIKE '%T.O.A.D%' OR -- Toad
     UPPER(v_prog) LIKE '%SQLNAV%' OR    -- SQL Navigator
     UPPER(v_prog) LIKE '%PLSQLDEV%' OR -- PLSQL Developer
     UPPER(v_prog) LIKE '%BUSOBJ%' OR   -- Business Objects
     UPPER(v_prog) LIKE '%EXCEL%'       -- MS-Excel plug-in
  THEN
     RAISE_APPLICATION_ERROR(-20000, 'Third party tools are not allowed on production database');
  END IF;
END;
/
Thanks

No comments:

Post a Comment

Translate >>