当前位置:主页 > IT技术分享 >

Oracle限制某个数据库帐号只能在特定机器上连入数据库

作者:AG88发表时间:2018-11-15

通过Oracle数据库的触发器实现,例如:TEST为测试账号、绑定的IP为:10.142.244.30
 
CREATE OR REPLACE TRIGGER sys.trg_work_log
AFTER LOGON ON DATABASE
declare
v_program_name varchar2(200);
v_username varchar2(100);
v_ip varchar2(18);
v_error varchar2(1000);
begin
select username,program,SYS_CONTEXT('USERENV','IP_ADDRESS')  
into v_username,v_program_name,v_ip
from sys.v_$session where AUDSID = SYS_CONTEXT('USERENV', 'SESSIONID');
if (upper(v_username)='TEST') then
  if (UPPER(v_program_name) = 'SQLPLUS.EXE') then
     if (v_ip = ('10.142.244.30')) then
       RAISE_APPLICATION_ERROR(-20001,'You are not allowed to connect to the database,err01');
         
    end if;
  ELSE
     RAISE_APPLICATION_ERROR(-20001,'不能使用sqlplus登陸');
        
  end if;
else
   RAISE_APPLICATION_ERROR(-20001,'You are not allowed to connect to the database');
  
end if;
 
END ;
/

http://www.bkjia.com/oracle/484286.htmlwww.bkjia.comtruehttp://www.bkjia.com/oracle/484286.htmlTechArticle通过Oracle数据库的触发器实现,例如:TEST为测试账号、绑定的IP为:10.142.244.30 CREATE OR REPLACE TRIGGER sys.trg_work_log AFTER LOGON ON DATABASE declare v_...

本文源自: 环亚娱乐

下一篇:没有了 上一篇:Oracle默认用户概述
IT技术分享
联系我们