作者:changless | 来源:互联网 | 2014-07-13 17:52
通过Oracle数据库的触发器实现,例如:TEST为测试账号、绑定的IP为:10.142.244.30CREATEORREPLACETRIGGERsys.trg_work_logAFTERLOGONONDATABASEdeclarev_program_namevarchar2(200);v_username...
通过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 ;
/