数据库登录触发器

use*_*853 5 trigger oracle access-control

为了阻止 Oracle 数据库上的特定用户和 IP 组合,我创建了以下触发器,并且编译没有错误。

Create or replace trigger you_may_not_login
after logon on database
begin
if sys_context('USERENV','SESSION_USER')='xx' AND     sys_context('USERENV','IP_ADDRESS')='10.0.30.219' then
raise_application_error(-20001,'Denied!  You are not allowed to logon the database');
end if;
end;
/
Run Code Online (Sandbox Code Playgroud)

当我使用 'xx' 用户登录时,警报日志显示以下错误,但访问权限已授予数据库,触发器以某种方式无法阻止用户登录。

Errors in file /oraarch/core/udump/wfsbi_ora_9338.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-20001: Sorry, you are not allowed here!
ORA-06512: at line 9
Run Code Online (Sandbox Code Playgroud)

我哪里错了?/

Jac*_*las 2

这个答案到 ServerFault 上的类似问题:

触发器不会拒绝访问,如果

  • 无法使用 ON LOGON 触发器断开 DBA 组成员的连接。
  • 触发器的所有者是登录的用户。
  • 用户具有管理数据库触发器的权限