Oracle如何限制某个IP段只能某些用户访问

 

Oracle如何限制某个IP段只能某些用户访问

 

如下触发器可以实现并且若有不符合的用户登录会将信息记录到警告日志:

 1 CREATE OR REPLACE TRIGGER logon_check_ip_user AFTER logoN ON DATABASE
 2 DECLARE
 3   error1 exception;
 4   ip       varchar2(60) := null;
 5   user     varchar2(60) := null;
 6   l_message  varchar2(2000);
 7 BEGIN
 8 SELECT sys_context('USERENV', 'IP_ADDRESS'),
 9        sys_context('USERENV' ,'AUTHENTICATED_IDENTITY')
10   into ip, user
11   from dual;
12 if ip = '192.168.1.40' AND upper(user) not in ('ZKM1','ZKM2') then
13   select 'Illegal login attempt to the "' ||
14          sys_context('USERENV', 'AUTHENTICATED_IDENTITY') || '" schema' ||
15          ' using ' || sys_context('USERENV', 'AUTHENTICATION_TYPE') ||
16          ' authentication' || ' at ' ||
17          to_char(logon_time, 'dd-MON-yy hh24:mi:ss') || ' from ' || osuser || '@' ||
18          machine || ' [' ||
19          nvl(sys_context('USERENV', 'IP_ADDRESS'), 'UnkNown IP') || ']' ||
20          ' via the "' || program || '" program.'
21     into l_message
22     from sys.v_$session
23    where sid = to_number(substr(dbms_session.unique_session_id, 1, 4), 'xxxx')
24      and serial# = to_number(substr(dbms_session.unique_session_id, 5, 4), 'xxxx');
25   raise error1;
26 end if;
27 exception
28   WHEN error1 THEN
29     sys.dbms_system .ksdwrt( 2,l_message );
30     raise_application_error(num => -20001,msg =>'Illegal login,permission denied! ');
31   WHEN others THEN 
32      raise_application_error(num => -20001,msg =>'Illegal login,permission denied! ');
33 END;
34 /

 

相关文章

Java Oracle 结果集是Java语言中处理数据库查询结果的一种方...
Java AES和Oracle AES是现代加密技术中最常使用的两种AES加密...
Java是一种广泛应用的编程语言,具备可靠性、安全性、跨平台...
随着移动互联网的发展,抽奖活动成为了营销活动中不可或缺的...
Java和Oracle都是在计算机领域应用非常广泛的技术,他们经常...
Java 是一门非常流行的编程语言,它可以运行于各种操作系统上...