os_authent_prefix参数详解(原创)

os_authent_prefix概述

通过操作系统用户认证的方式来直接访问Oracle数据库,简单来说,如果配置了该参数例如为'czm$',当数据库中存在用户'czm$hr',且对该用户启用了外部验证。那么在操作系统上以hr用户登录成功后,就可以直接sqlplus /以czm$hr用户登陆到Oracle数据库,无需sqlplus username/password输入访问Oracle数据库的用户名和密码。
实例如下

查看用户是否启用外部验证

SQL> show parameter os_authent_prefix

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
os_authent_prefix                    string        czm$


SQL> select USERNAME,PASSWORD from  dba_users where username='CZM$HR';

USERNAME                       PASSWORD
------------------------------ ------------------------------
CZM$HR                         EXTERNAL

以hr用户登录

[hr@dg1 ~]$ id
uid=502(hr) gid=504(hr) groups=500(oinstall),504(hr)

设置环境变量

[hr@dg1 ~]$ export ORACLE_SID=czmmiao
[hr@dg1 ~]$ export PATH=/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/oracle/bin:/home/oracle/bin:/u01/app/oracle/product/10.2.0/db_1/bin
[hr@dg1 ~]$ export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

登录数据库

[hr@dg1 ~]$ sqlplus /
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Nov 7 17:11:10 2011
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

SQL> show user;
USER is "CZM$HR"

注意,当os_authent_prefix为空时,表示如果操作系统上存在与数据库用户同名的用户即可直接登录数据库。

示例如下

SQL> alter system set os_authent_prefix='' scope=spfile;
System altered.

SQL> alter user hr identified externally;
User altered.

SQL> startup force;
ORACLE instance started.

Total System Global Area  373293056 bytes
Fixed Size                  1219496 bytes
Variable Size             197133400 bytes
Database Buffers          171966464 bytes
Redo Buffers                2973696 bytes
Database mounted.
Database opened.


SQL> show parameter os_authent_prefix

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
os_authent_prefix                    string


用hr用户登录数据库

[hr@dg1 ~]$ sqlplus /
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Nov 7 17:14:26 2011
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

SQL> show user;
USER is "HR"

由于这种验证方式对安全性有较大隐患,Oracle不建议采用这种方式进行验证。


参考至:《教你成为10g OCP》韩思捷著

本文原创,转载请注明出处、作者

如有错误,欢迎指正

邮箱:[email protected]

你可能感兴趣的:(pre)