Jun 6, 2019

Restrict connectivity from other tools to your database

This trigger can help you to restrict connectivity from other tools to your database:

rem -----------------------------------------------------------------------
rem Filename:   RestricTools.sql
rem Purpose:    Restrict your critical production database from using TOAD or PLSQL Developer and other tools.
rem Date:       06-Jun-2019
rem Author:     Gouranga Mohapatra
Rem Remark:     To be created from sys user
rem -----------------------------------------------------------------------

CONNECT / AS SYSDBA;

CREATE OR REPLACE TRIGGER trg_block_tools
  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;
/

No comments:

Post a Comment

Translate >>