暂无图片
分享
莫得感情的萝卜头
2019-03-18
创建trigge禁止navicat登录

trigger内容:

create or replace TRIGGER sys.flaginfo_logon_control

  AFTER LOGON ON DATABASE

DECLARE

  v_sid  varchar2(10);

  v_serial# varchar2(10);

  my_forced_exception EXCEPTION;

  PRAGMA EXCEPTION_INIT(MY_FORCED_EXCEPTION, -20101);

BEGIN

  IF ( sys_context('USERENV', 'SESSION_USER') LIKE ('SYS%')) -- add your username here

   THEN

    IF (UPPER(sys_context('USERENV', 'MODULE')) LIKE '%NAVICAT%'  ) --SQL DEVELOP

     THEN

      

      RAISE my_forced_exception;

    END IF;

  END IF;

EXCEPTION

  WHEN my_forced_exception THEN

    RAISE_APPLICATION_ERROR(-20101,

                            'USER ' ||

                            sys_context('USERENV', 'SESSION_USER') || ' ' ||

                            'MODULE ' ||

                            UPPER(sys_context('USERENV', 'MODULE')) || ' ' || '

                              Logon Action via tool is not allowed');

  WHEN OTHERS THEN

    null;

END;


登录有alter.log有记录

Mon Mar 18 13:07:43 2019

Errors in file /opt/oracle/admin/ltdb/udump/ltdb_ora_22162.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-20101: USER SYS MODULE NAVICAT PREMIUM@STONEDEMACBOOK-PRO.LOCAL (TNS V1 

                              Logon Action via tool is not allowed

ORA-06512: at line 17



oracle@odb-wx045-s172:~$ more  /opt/oracle/admin/ltdb/udump/ltdb_ora_22162.trc

/opt/oracle/admin/ltdb/udump/ltdb_ora_22162.trc

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORACLE_HOME = /opt/oracle/product/10.2.0.4.0/db_1

System name:    Linux

Node name:      odb-wx045-s172

Release:        2.6.32-573.el6.x86_64

Version:        #1 SMP Thu Jul 23 15:44:03 UTC 2015

Machine:        x86_64

Instance name: ltdb

Redo thread mounted by this instance: 1

Oracle process number: 781

Unix process pid: 22162, image: oracle@odb-wx045-s172

*** ACTION NAME:() 2019-03-18 13:07:43.320

*** MODULE NAME:(Navicat Premium@stonedeMacBook-Pro.local (TNS V1) 2019-03-18 13:07:43.320

*** SERVICE NAME:(SYS$USERS) 2019-03-18 13:07:43.320

*** SESSION ID:(4814.13060) 2019-03-18 13:07:43.320

Error in executing triggers on connect internal

*** 2019-03-18 13:07:43.320

ksedmp: internal or fatal error

ORA-00604: error occurred at recursive SQL level 1

ORA-20101: USER SYS MODULE NAVICAT PREMIUM@STONEDEMACBOOK-PRO.LOCAL (TNS V1 

                              Logon Action via tool is not allowed

ORA-06512: at line 17


收藏
分享
4条回答
默认
最新
Moone

Good Job!


暂无图片 评论
暂无图片 有用 0
莫得感情的萝卜头

你好, trigger正常编译,alter日志也有记录,但是navicat可以登录数据库。

暂无图片 评论
暂无图片 有用 0
盖国强

以下这段代码,不要放在Exception里。


RAISE_APPLICATION_ERROR(-20101,

                            'USER ' ||

                            sys_context('USERENV', 'SESSION_USER') || ' ' ||

                            'MODULE ' ||

                            UPPER(sys_context('USERENV', 'MODULE')) || ' ' || '

                              Logon Action via tool is not allowed');


暂无图片 评论
暂无图片 有用 0
章芋文
问题已关闭: 问题已经得到解决
暂无图片 评论
暂无图片 有用 0
回答交流
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
暂无图片墨值悬赏