proxy uesr的一点测试

有些时候我们可能需要以其他用户的身份登录db做一些事情(切换用户的身份),这个时候就需要知道其他用户的口令,如果不知道的话就无法实现,当然oracle中也有不太理想的办法来实现,从10。2开始,oracle提出了proxy user的概念可以很好的实现。[@more@]

--简单的测试了一下,应该是10.2提出的agent user的概念
SQL> create user test1 identified by test1;

用户已创建。

SQL> create user test2 identified by test2;

用户已创建。

SQL> grant connect to test1,test2;

授权成功。

SQL> alter user test2 grant connect through test1;

用户已更改。

SQL> connect test1[test2]/test1 --test1用户代理test2用户
已连接。
SQL> show user
USER 为 "TEST2"
SQL> exit
从 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options 断开

C:>sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期二 11月 17 11:25:51 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.


连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> grant alter system , unlimited tablespace,create table to test2;

授权成功。

SQL> grant alter session , unlimited tablespace,create table to test1;

授权成功。

SQL> connect test1[test2]/test1
已连接。
SQL> show user
USER 为 "TEST2"
--显然登录用户还是test2,当然session中的权限也是test2用户的权限
SQL> select *from session_privs;

PRIVILEGE
----------------------------------------
ALTER SYSTEM
CREATE SESSION
UNLIMITED TABLESPACE
CREATE TABLE

SQL> create table t_agent(id int);

表已创建。

SQL> connect / as sysdba
已连接。
SQL> select owner from dba_tables where table_name='T_AGENT';

OWNER
------------------------------
TEST2

SQL>
--一切操作似乎和test1无关
--======================================

--在没有agent user之前,如果我们想以test1的身份登录db的话(如果事先不知道test1的口令)需要先保留test1的password:

SQL> select password from dba_users where username='TEST1';

PASSWORD
------------------------------
22F2E341BF4B8764

SQL> alter user test1 identified by test123;

用户已更改。

SQL> connect test1/test123
已连接。
SQL> show user
USER 为 "TEST1"
SQL>

此时可以在这个session中以test1用户的身份工作

那么在另一个session中最好理解把test1的口令改回去,防止test1用户登录时出现口令错误提示:

C:>sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期二 11月 17 11:56:57 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.


连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> alter user test1 identified by values '22F2E341BF4B8764';

用户已更改。

SQL> connect test1/test1
已连接。
SQL>

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

转载于:http://blog.itpub.net/19602/viewspace-1028790/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值