首页 > 代码库 > Oracle操作系统身份验证

Oracle操作系统身份验证

此技术使用与操作系统用户同样的名称创建Oracle用户,但前面加上了os_authent_prefix参数指定的字符串,默认为ops$,下面我们来看看官档对该参数的说明:

OS_AUTHENT_PREFIX specifies a prefix that Oracle uses to authenticate users attempting to connect to the server. Oracle concatenates the value of this parameter to the beginning of the user‘s operating system account name. When a connection request is attempted, Oracle compares the prefixed username with Oracle usernames in the database.

The default value of this parameter is OPS$ for backward compatibility with previous versions. However, you might prefer to set the prefix value to "" (a null string), thereby eliminating the addition of any prefix to operating system account names.

可见,用ops$只是为了向前兼容。

下面,我们来实验一下。

一、创建操作系统用户

     [root@node1 ~]# useradd test

二、创建Oracle用户并授予相应的权限

     SQL> create user ops$test identified externally;

     SQL> grant create session to ops$test;

三、用test用户登录数据库

[test@node1 ~]$ /u01/app/oracle/product/11.2.0.4/db_1/bin/sqlplus /Error 6 initializing SQL*PlusSP2-0667: Message file sp1<lang>.msb not foundSP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

    报以上错误,根据提示,我们为ORACLE_HOME设置响应的值

    在/home/test/.bash_profile中添加如下值:   

export ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db_1

    重新用test用户登录数据库

[test@node1 ~]$ /u01/app/oracle/product/11.2.0.4/db_1/bin/sqlplus /SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 10 01:14:53 2015Copyright (c) 1982, 2013, Oracle.  All rights reserved.ERROR:ORA-12162: TNS:net service name is incorrectly specifiedEnter user-name: 

    又报TNS:net service name is incorrectly specified错误。

    怀疑没有指定响应的SID,在/home/test/.bash_profile中添加如下值:

export ORACLE_SID=orcl

    重新用test用户登录    

[test@node1 ~]$ /u01/app/oracle/product/11.2.0.4/db_1/bin/sqlplus /SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 10 01:18:22 2015Copyright (c) 1982, 2013, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - ProductionWith the Partitioning, Automatic Storage Management, OLAP, Data Miningand Real Application Testing optionsSQL> show userUSER is "OPS$TEST"

    终于成功登录!

 

    

 

Oracle操作系统身份验证