[Oracle] 如何使用触发器实现IP限制用户登录建站知
导读:1建站知识在Oracle里,不像MySQL那样方便,可以直接在用户上进行IP限制,Oracle要实现用户级别的IP限制,可以使用触发器来迂回网站建设公司营销型网站建设。
下面是一个触发器的例子:
复制代码 代码如下:
create or replace trigger logon_ip_controlafter logon on databasedeclare ip STRING(30); user STRING(30);beginSELECT SYS_CONTEXT('USERENV','SESSION_USER') into user from dual;SELECT SYS_CONTEXT('USERENV','IP_ADDRESS') into ip from dual;if user='EPAY_USER' THEN IF ip not in ('192.168.219.20','192.168.219.22') THEN raise_application_error(-20001,'User '||user||' is not allowed to connect from '||ip); END IF;END IF;end;/
该触发器对用户EPAY_USER进行了IP限制(只允许'192.168.219.20','192.168.219.22'建设网站,如果需要设置IP段,用%或?代替即可,如'192.168.219.%‘)。下面看几个例子测试一下:1)从非允许IP地址登陆 (192.168.219.21),连接失败复制代码 代码如网站建设制作下:
[oracle@lxdb2 ~]$ sqlplus epay_user@priSQL*Plus: Relea网站seo优化诊断工具se 11.2.0.3.0 Production on Wed Jul 3 19:23:48 2013Copyright (c) 1982, 2011, Oracle. All rights reserved.Enter password: ERROR:ORA-00604: error occurred at recursive SQL level 1ORA-20001: User EPAY_USER is not allowed to connect from 192.168.219.21ORA-06512: at line 10
2)从允许IP地址登陆(192.168.219.22),连接成功复制代码 代码如下:
[oracle@lxdb1 ~]$ sqlplus epay_userSQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 3 11:24:25 2013Copyright (c) 1982, 2011, Oracle. All rights reserved.Enter password: Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options
3)从本地登陆(192.168.219.23)不受IP限制影响,连接成功复制代码 代码如下:
[oracle@lxdb1 ~]$ sqlplus epay_userSQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 3 11:24:25 2013Copyright (c) 1982, 2011, Oracle. All rights reserved.Enter password: Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options
相关网站建设公司营销型网站建设。声明: 本文由我的SEOUC技术文章主页发布于:2023-05-22 ,文章[Oracle] 如何使用触发器实现IP限制用户登录建站知主要讲述触发器,用户登录,IP网站建设源码以及服务器配置搭建相关技术文章。转载请保留链接: https://www.seouc.com/article/web_5054.html