欢迎光临
我们一直在努力

使用product_user_profile来实现用户权限的设定-数据库专栏,SQL Server

建站超值云服务器,限时71元/月

使用product_user_profile来实现用户权限的设定

author:kamus
mail:kamus@itpub.net
date:2004-1

我们有时候在以普通用户登录sql*plus的时候,会碰到下面的错误提示:
error accessing product_user_profile
warning: product user profile information not loaded!
you may need to run pupbld.sql as system

其实在实际意义上这只是一个警告而已,并不是真正的错误,遇到这个提示,并不会影响我们正常使用sql*plus,也不会对数据库功能产生影响。

如果数据库是使用dbca创建的那么不用担心这个问题,通常是我们手动创建数据库的情况下,忘了执行一些脚本才导致出现这样的警告。product_user_profile其实有很强大的功能,这是system模式下的一个表,在此表中存在的数据可以让客户端程序登入的时候检查是否在命令的执行上有什么限制。基本上我们是以它来限制sql*plus这个客户端程序(目前好像也只有这个程序才会去自动检查这张表:d)

如果不想看到这个警告,作如下操作:
以system用户登入sql*plus,然后执行pupbld.sql,这个文件通常在$oracle_home/sqlplus/admin目录中。
sql> @$oracle_home/sqlplus/admin/pupbld.sql

执行完毕以后,可以desc product_user_profile来验证一下改表已经创建,并且熟悉一下表的结构。

以上不是这篇小文章的重点,下面我们要利用这张表来限制scott用户不能执行drop命令,即使scott用户拥有drop table的权限。
sql> insert into product_user_profile (
  2  product, userid, attribute, char_value)
  3  values (
  4  sql*plus,scot%,drop,disabled);

1 row inserted

executed in 0.01 seconds

sql> commit;

commit complete

executed in 0 seconds

然后退出system用户,用scott用户登录,作个测试:
sql> create table t_test_profile(
  2  id number);

table created.

elapsed: 00:00:00.10

sql> drop table t_test_profle;
sp2-0544: invalid command: drop

这就是product_user_profile的作用,回顾一下:
1。如果我们把drop改成create或者update那么就对用户禁止了这些命令。
2。从上面的insert语句,我们可以看到对于用户的限制支持通配符,所有以scot开头的用户都不能执行指定的命令。
3。修改了product_user_profile内容,用户必须重新登录sql*plus,修改才会生效,也就是只有在登录的时候,sql*plus才会检查一遍product_user_profile表中的内容。

 

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 使用product_user_profile来实现用户权限的设定-数据库专栏,SQL Server
分享到: 更多 (0)