你好,游客 登录 注册 搜索
背景:
阅读新闻

Oracle限制IP登录

[日期:2009-09-17] 来源:hi.baidu.com/sh_wu  作者:sh_wu [字体:大 中 小]

二、使用触发器
由于sqlnet.ora方式不支持IP段,对于某个IP段的限制,可以使用触发器实现
1、需求:限制IP段 192.168.137登录
2、实现方式:
Oracle@oracle[/oracle/app/10g/network/admin]> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jun 15 12:25:32 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
sys@ORCL>
sys@ORCL> create or replace trigger chk_ip
2 after logon on scott.schema
3 declare
4 ipaddr VARCHAR2(30);
5 begin
6 select sys_context('userenv', 'ip_address') into ipaddr from dual;
7 if ipaddr like ('192.168.137.%') then
8 raise_application_error('-20001', 'you can not logon by scott');
9 end if;
10 end chk_ip;
11 /
Trigger created.
sys@ORCL>
在192.168.137.1上登录,显示:
ORA-00604: error occurred at recursive SQL level 1
ORA-20001: you can not logon by scott
ORA-06512: at line 6
显然使用触发器会带来更多便利

linux
相关资讯       oracle 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款