首页 > 数据库 > Oracle > 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@localhost ~]$ id
uid=500(oracle) gid=1000(oinstall) groups=1000(oinstall),1201(asmdba),1300(dba),1301(oper) context=root:syst
SQL> show parameter os_authent_prefixops$SQL> show parameter os_authent_prefix
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
os_authent_prefix string ops$
SQL> create user ops$oracle identified by externally ;
User created.
没有给用户connect角色无法连接:
[oracle@localhost ~]$ sqlplus /
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jul 23 17:51:48 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
ERROR:
ORA-01045: user OPS$ORACLE lacks CREATE SESSION privilege; logon denied
赋予权限后,就可以登录:
SQL> grant connect to ops$oracle;
Grant succeeded.
[oracle@localhost ~]$ sqlplus /
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jul 23 17:52:26 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
SQL> show user;
USER is "OPS$ORACLE"
由于这种验证方式对安全性有较大隐患,Oracle不建议采用这种方式进行验证。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28194062/viewspace-1746033/ ,如需转载,请注明出处,否则将追究法律责任。