---
title: "使用SEC_CASE_SENSITIVE_LOGON参数控制密码大小写敏感性"
author: "libin123"
date: "2010-10-19T15:55:46Z"
tags: []
categories: ["数据库"]
slug: "sec-case-sensitive-logon"
draft: false
lastmod: "2010-10-19T15:56:24Z"
id: 788642
url: "https://dbua.iteye.com/blog/788642"
---

在[**Oracle**]()的[**11g**]()之前的版本中密码是不区分[**大小写**]()的（使用双引号强制除外）。在Oracle的11g版本中对此有所增强。从此密码有了大小写的区分，这个大小写敏感特性是通过SEC\_CASE\_SENSITIVE\_LOGON参数来控制的。简单探索一下。

1.创建[**Secooler**]()用户，注意它的密码同时包含大写字母和小写字母。  
sys@ora11gR2&gt; create user Secooler identified by Secooler;

User created.

sys@ora11gR2&gt; grant connect to secooler;

Grant succeeded.

从这个授权成功上可见，用户名仍然不区分大小写。

2.尝试使用全小写的密码登陆  
sys@ora11gR2&gt; conn secooler/secooler  
ERROR:  
ORA-01017: invalid username/password; logon denied

Warning: You are no longer connected to ORACLE.

报错，显然不行，此时大小写[**敏感性**]()检查已经启用。

3.使用“正确”的密码“Secooler”进行登陆，成功。  
sys@ora11gR2&gt; conn secooler/Secooler  
Connected.  
secooler@ora11gR2&gt; show user;  
USER is "SECOOLER"

4.看一下“幕后黑手”SEC\_CASE\_SENSITIVE\_LOGON参数的描述  
sys@secooler&gt; show parameter sec\_case\_sensitive\_logon

NAME                       TYPE       VALUE  
\-------------------------- ---------- -----------  
sec\_case\_sensitive\_logon   boolean    TRUE

sys@ora11gR2&gt; select a.ksppinm name,b.ksppstvl value,a.ksppdesc description  
  2    from x$ksppi a,x$ksppcv b  
  3   where a.indx = b.indx  
  4     and a.ksppinm = 'sec\_case\_sensitive\_logon'  
  5  /

NAME                      VALUE  DESCRIPTION  
\------------------------- ------ -----------------------------------------  
sec\_case\_sensitive\_logon  TRUE   case sensitive password enabled for logon

该参数默认值是“TRUE”，因此，默认情况下密码大小写是敏感的。

5.将SEC\_CASE\_SENSITIVE\_LOGON参数修改为“FALSE”  
sys@ora11gR2&gt; alter system set sec\_case\_sensitive\_logon = FALSE;

System altered.

6.此时系统将不对密码做大小写敏感验证  
sys@ora11gR2&gt; conn secooler/secooler  
Connected.

7.即使修改SEC\_CASE\_SENSITIVE\_LOGON参数为“FALSE”，在系统中记录的也是区分大小写的形式，只是不进行验证而已。  
1）创建另外一个用户sec，并授权  
sys@ora11gR2&gt; create user sec identified by SeC;

User created.

sys@ora11gR2&gt; grant connect to sec;

Grant succeeded.

2）在SEC\_CASE\_SENSITIVE\_LOGON参数为“FALSE”时尝试连接，成功，因为此时不进行校验。  
sys@ora11gR2&gt; conn sec/sec  
Connected.

3）恢复SEC\_CASE\_SENSITIVE\_LOGON参数为“TRUE”，再次尝试连接将会失败。  
sec@ora11gR2&gt; conn / as sysdba  
Connected.  
sys@ora11gR2&gt; alter system set sec\_case\_sensitive\_logon = TRUE;

System altered.

sys@ora11gR2&gt; conn sec/sec  
ERROR:  
ORA-01017: invalid username/password; logon denied

Warning: You are no longer connected to ORACLE.

4）使用“正确”的密码进行尝试，成功。  
sys@ora11gR2&gt; conn sec/SeC  
Connected.

5）结论  
11g环境中密码是以区分大小写的形式进行存储的。

8.Oracle 11g文档参考（11gR1和11gR2内容相同）  
http://download.oracle.com/docs/cd/E11882\_01/server.112/e10820/initparams218.htm#REFRN10299

# SEC\_CASE\_SENSITIVE\_LOGON[]()[]()

  Property Description Parameter type Boolean Default value `true` Modifiable `ALTER SYSTEM` Range of values `true | false` Basic No

&lt;!-- class="inftblinformal" --&gt;

`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.

9.小结  
11g的这个密码大小写敏感的新特性对于提升[**数据库**]()的[**安全性**]()有很大的帮助，同时也增加了密码的排列组合数目，从此“Secooler”和“secooler”可以作为两个不同用户的密码了。从这个小小的改动上可以看出Oracle诸多人性化改变无处不在。

Good luck.