ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 限制用户在某个网段Logon实现trigger

限制用户在某个网段Logon实现trigger

原创 Linux操作系统 作者:gdutllf2006 时间:2010-05-29 21:16:05 0 删除 编辑

create table system.t_validip( IP_ADDRESS VARCHAR2(20),USERNAME   VARCHAR2(20)) tablespace users;

insert into system.t_validip values('10.230.12.2','*');
insert into system.t_validip values('10.230.12.3','*');
insert into system.t_validip values('10.230.12.4','*');
insert into system.t_validip values('10.230.11.2','*');
commit;

create trigger sys.login_on_info
after logon on database
declare
  s_username varchar2(20);

  s_machine varchar2(100);
  s_ip  varchar2(100);

  i  number;

Begin
    s_username := upper(user);
    s_machine := substrb(sys_context('USERENV','HOST'),1,100);
    s_ip := SYS_CONTEXT('USERENV','IP_ADDRESS');
    if s_username in ('MTAMANAGER', 'MAILCONTENT') then
      if ( s_ip is null) then
        null;
      else
       select count(*) into i from system.t_validip where ip_address=s_ip and (username='*' or username=s_username);
        if i=0 then
                  raise_application_error(-20010,'INVALID USER!('||s_username||','||s_ip||')');
    end if;
        end if;
      end if;
end;
     

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10248702/viewspace-663987/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: RMAN异地恢复测试
请登录后发表评论 登录
全部评论

注册时间:2009-07-08

  • 博文量
    133
  • 访问量
    425853