Oracle 10g 11g密码策略 用户口令 大小写敏感 说明

一、Oracle 10g

1、说明

Oracle 10g下,默认情况下,密码是不区分大小写的。这个是由于密码文件的默认参数有关。

C:\Users\Administrator >orapwd

Usage: orapwd file=entries= force= ignorecase=nosysdba=

 

 where

   file - name of password file (required),

   password - password for SYS will be prompted if not specified at commandline,

   entries - maximum number of distinct DBA (optional),

   force - whether to overwrite existing file (optional),

   ignorecase - passwords are case-insensitive (optional),

   nosysdba - whether to shut out the SYSDBA logon (optional Database Vaultonly).

 

 There must be no spaces around the equal-to (=) character.

这个是口令文件创建命令的参数说明, 这里我们看一个参数:ignorecase - passwords are case-insensitive (optional)

注意:

     这个参数用来指定大小写是否敏感,而默认情况是insentive 即不敏感,所以对于Oracle10g的数据库,默认情况下,密码是不区分大小写的。但是在Oracle 10g中,我们无法使用这个参数,在后续的测试用有说明

虽然口令文件里只保存具有SYSDBAOPER权限的用户,但是其他用户也会受影响。

2、示例

这里我们在Oracle 10g上做一个测试,为了避免OS认证的影响,我们这里可以禁用OS认证。

SQL> select * from v$version;

BANNER

-------------------------------------------------

Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod

PL/SQL Release 10.2.0.3.0 - Production

CORE    10.2.0.3.0      Production

TNS for 32-bit Windows: Version 10.2.0.3.0 - Production

NLSRTL Version 10.2.0.3.0 - Production

--创建2个测试用户

SQL> create user usr1 identified by USr1;

用户已创建。

SQL> create user usr2 identified by USr2;

用户已创建。

SQL> grant connect,resource to usr1;

授权成功。

SQL> grant connect,resource to usr2;

授权成功。

SQL> grant sysdba,sysoper to usr1;

授权成功。

SQL> select * from v$pwfile_users;

USERNAME                       SYSDB SYSOP

------------------------------ ----- -----

SYS                            TRUE  TRUE

LXH                            TRUE  FALSE

USR1                           TRUE  TRUE

SQL> conn usr1/usr1;

已连接。

SQL> conn usr2/usr2;

已连接。

SQL> conn usr1/uSR1;

已连接。

SQL> conn usr1/lxh;

ERROR:

ORA-01017: 用户名/口令无效; 登录被拒绝

警告: 您不再连接到 ORACLE

从这里可以看出,在Oracle 10g下,密码是不分大小写的。

--继续测试

我们将sysdba权限从usr1用户revoke,然后测试:

SQL> conn sys/system as sysdba

已连接。

SQL> revoke sysdba,sysoper from usr1;

撤销成功。

SQL> select * from v$pwfile_users;

USERNAME                       SYSDB SYSOP

------------------------------ ----- -----

SYS                            TRUE  TRUE

LXH                            TRUE  FALSE

我们继续使用usr1进行测试:

SQL> conn usr1/usr1;

已连接。

SQL> conn usr1/lxh;

ERROR:

ORA-01017: 用户名/口令无效; 登录被拒绝

警告: 您不再连接到 ORACLE

从这里可以看出,只是简单的revoke并不能解决问题,我们重建一个口令文件,然后测试一下看看:

E:\oracle\product\10.2.0\db_1\database>orapwd file=orapwtest password=oracle force=y;

SQL> conn usr1/usr1;

已连接。

--还是可以继续使用,不分大小写。

DB重启一下看看:

SQL> shutdown immediate

ORA-01031: 权限不足

SQL> conn sys/system as sysdba

已连接。

SQL> startup

ORACLE 例程已经启动。

Total System Global Area  377487360 bytes

Fixed Size                  1290688 bytes

Variable Size             352325184 bytes

Database Buffers           16777216 bytes

Redo Buffers                7094272 bytes

数据库装载完毕。

数据库已经打开。

SQL> conn usr1/usr1;

已连接。

所以我们重建口令文件不能解决问题。所以在Oracle 10g中,密码是不区分大小写的,这种现状,在Oracle 11g中才得到真正的改善。

Oracle 10g中:

E:\oracle\product\10.2.0\db_1\database>orapwd file=orapwtest password=oracle force=y ignorecase=y

Usage: orapwd file= password= entries= force= nosysdba=

  where

    file - name of password file (mand),

    password - password for SYS (mand),

    entries - maximum number of distinct DBA,

    force - whether to overwrite existing file (opt),

    nosysdba - whether to shut out the SYSDBA logon (opt for Database Vault only).

  There are no spaces around the equal-to (=) character.

这里设置了ignorecase参数之后,orapwd命令无法正常运行。因为ignorecase是在oracle 11g中真正新增的功能,在Oracle 11g中才可以使用。该参数用于设置sysdbasysoper权限通过密码文件登录时是否区分大小写。

二、Oracle 11g

1、说明

1)、sec_case_sensitive_logon参数

Oracle 11g中,Oracle开始区分密码大小写,这个由参数:SEC_CASE_SENSITIVE_LOGON决定:

Property

Description

Parameter type

Boolean

Default value

true

Modifiable

ALTER SYSTEM

Range of values

true | false

Basic

No

SEC_CASE_SENSITIVE_LOGON enables or disables password case sensitivity in the database.

Values:

true: Database logon passwords are case sensitive.

false:Database logon passwords are not case sensitive.

用户如果是从Oracle 10g导入的,那么PASSWORD_VERSIONS的值就是“10g”,维护区分大小写的密码不依赖于SEC_CASE_SENSITIVE_LOGON参数设置。假设SEC_CASE_SENSITIVE_LOGON参数被设置为TRUE,密码立即变为大小写敏感。

2)、口令文件

C:\Users\Administrator >orapwd

Usage: orapwd file=entries= force= ignorecase=nosysdba=

 

 where

   file - name of password file (required),

   password - password for SYS will be prompted if not specified at commandline,

   entries - maximum number of distinct DBA (optional),

   force - whether to overwrite existing file (optional),

   ignorecase - passwords are case-insensitive (optional),

   nosysdba - whether to shut out the SYSDBA logon (optional Database Vaultonly).

 

 There must be no spaces around the equal-to (=) character.

orapwd工具的ignorecase参数允许你控制在密码文件中的密码是否大小写敏感,它的默认值是“n”,即默认大小写敏感。如果特权用户(SYSDBASYSOPER)是从之前的数据库版本中导入的,它们的密码也会包括在密码文件中,这些用户将会保留大小写敏感的密码,直到密码被修改。

如果指定ignorecase=y,则Oracle会忽略密码验证时密码的大小写。

示例一:

SQL> show parameter sec_case_sensitive_logon

NAME                                TYPE        VALUE
------------------------------------ ----------- ------------------------------
sec_case_sensitive_logon            boolean     TRUE

--创建测试用户:

SQL> create user dave identified byDavE;

User created.

SQL> grant connect,resource to dave;

Grant succeeded.

 

SQL> conn dave/dave;

ERROR:

ORA-01017: invalid username/password; logondenied

 

Warning: You are no longer connected toORACLE.

SQL> conn dave/DavE;

Connected.

--这里区分大小写

 

 

--修改参数:

SQL> conn / as sysdba;

Connected.

SQL> alter system set sec_case_sensitive_logon=false;

System altered.

 

SQL> show parametersec_case_sensitive_logon

NAME                    TYPE        VALUE

----------------------------------------------- -------

sec_case_sensitive_logon     boolean    FALSE

 

SQL> conn dave/dave;

Connected.

--禁用sec_case_sensitive_logon 就不区分大小写了。

示例二:

在上面我们是通过sec_case_sensitive_logon 来设置的,这里我们通过口令文件参数来进行设置。

Oracle 11g中,口令文件的ignorecase 参数用于设置sysdbasysoper权限通过密码文件登陆时是否区分大小写。默认情况下,ignorecase 参数是区分大小写的。

注意这里的ingorecase 参数仅仅是在密码文件中创建大小写敏感的密码。

先禁用OS认证

SQL>show parametersec_case_sensitive_logon

 

NAME                                 TYPE        VALUE

----------------------------------------------- ------

sec_case_sensitive_logon             boolean     TRUE

 

 

C:\Users\Administrator.DavidDai>orapwdfile=D:\app\Administrator\product\11.2.0\dbhome_1\database\pwdDAVE.orapassword=OraclE force=y ignorecase=y

 

 

--测试ignorecase参数对赋予sysdba 权限用户的影响:

C:\Users\Administrator.DavidDai>

 

SQL> conn / as sysdba

Connected.

SQL> create user dave1 identified byDavE;

User created.

 

SQL> grant connect,resource to dave1;

Grant succeeded.

 

SQL> conn dave1/dave;

ERROR:

ORA-01017: invalid username/password; logondenied

 

Warning: You are no longer connected toORACLE.

SQL> conn dave1/DavE;

Connected.

--这里也必须使用正确的密码,包括大小写。

 

SQL> conn / as sysdba;

Connected.

 

SQL> grant sysdba,sysoper to dave1;

Grant succeeded.

 

SQL> select * from v$pwfile_users;

USERNAME                       SYSDB SYSOP SYSAS

------------------------------ ----- ----------

SYS                            TRUE  TRUE FALSE

DAVE1                          TRUE  TRUE FALSE

 

SQL> conn dave1/DavE;

Connected.

SQL> conn dave1/dave;

ERROR:

ORA-01017: invalid username/password; logondenied

 

 

Warning: You are no longer connected to ORACLE.

--通过这个测试我们可以看出,在创建口令文件时对后来赋予sysdba权限的用户来说,没有影响,不能指定其是否忽略大小写。

--测试SYS 用户:

我们创建口令文件时就是针对这个这个用户的。

 

SQL> conn sys/oracle as sysdba;

Connected.

SQL> conn sys/OraclE as sysdba;

Connected.

SQL> conn sys/dave as sysdba;

ERROR:

ORA-01017: invalid username/password; logondenied

 

 

Warning: You are no longer connected toORACLE.

--这里SYS 用户成功忽略了大小写问题。

总结:

通过以上2个测试,可以得出结论:

1sec_case_sensitive_logon参数可以指定用户的口令是否区分大小写。

2)口令文件中的ignorecase 参数仅仅针对创建时是否区分大小写,简言之,只能争对SYS用户。

三、Oracle 10g,11gDBlink

通过前面的说明,可以看到Oracle 10g11g中对密码出的验证策略不同,所以如果在不同版本库之间建DBLINK,那么密码也就会成为一个问题,可能出现密码不对的问题,具体的注意事项如下:

111g连接到11g

创建数据库连接时,密码必须与远程数据库用户的密码大小写一致。

211g连接到11g以前的数据库:

创建数据流连接时用的密码大小写随意,因为远程数据库会忽略大小写的。

311g以前的数据库连接到11g

将远程用户的密码修改为大写,或者用引号括起来,只有这样才能通过11g以前的数据库验证。

请使用浏览器的分享功能分享到微信等