To limiting access of a user to a database based on time interval. We can prevent a specific user to access to a database between 08 and 22.
created a logon script and see how it’s working:
To prevent users from using additional tools to connect to production database. This is the AFTER LOGON trigger create ON DATABASE as follows:
created a logon script and see how it’s working:
C:\Documents and Settings\Administrator>sqlplus "/as sysdba" SQL*Plus: Release 10.2.0.1.0 - Production on Tue Jul 28 14:56:58 2009 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL> create user kan identified by kan; User created. SQL> grant connect, resource to kan; Grant succeeded. SQL> conn kan/kan Connected. SQL> disc Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Pr oduction With the Partitioning, OLAP and Data Mining options SQL> conn / as sysdba Connected. SQL> CREATE OR REPLACE TRIGGER limit_connection 2 AFTER LOGON ON DATABASE 3 BEGIN 4 IF USER = 'KAN' THEN 5 IF to_number(TO_CHAR (SYSDATE, 'hh24')) BETWEEN 8 AND 22 6 THEN 7 RAISE_APPLICATION_ERROR(-20998,' Dear user '||USER||'! You can''t login between 08 and 22'); 8 END IF; 9 END IF; 10 END limit_connection; 11 / Trigger created. SQL> select to_char(sysdate,'hh24') from dual; TO -- 23 SQL> conn kan/kan Connected. SQL> select to_char(sysdate,'hh24') from dual; TO -- 18 SQL> conn kan/kan ERROR: ORA-00604: error occurred at recursive SQL level 1 ORA-20998: Dear user KAN! You can't login between 08 and 22 ORA-06512: at line 5 Warning: You are no longer connected to ORACLE. SQL>
To prevent users from using additional tools to connect to production database. This is the AFTER LOGON trigger create ON DATABASE as follows:
CONNECT / AS SYSDBA; CREATE OR REPLACE TRIGGER 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, 'Development tools are not allowed here.'); END IF; END; / SHOW ERRORS
No comments:
Post a Comment