Oracle以 IDENTIFIED BY VALUES 密码创建的用户连接时报错ORA-01017

 

Oracle以 IDENTIFIED BY VALUES 密码创建的用户连接时报错ORA-01017

 

在Oracle11G中,创建用户后,可以在user$.password查询到一串加密后的密码,如下:

10:05:07 SYS@qadb(490)> create user zkm1 identified by oracle;

User created.

Elapsed: 00:00:00.04
10:05:13 SYS@qadb(490)> select NAME, password from user$ where NAME in ('ZKM1');

NAME            PASSWORD
--------------- -----------------------------------
ZKM1            F1B9117FB233B1EB

Elapsed: 00:00:00.00

 

在数据泵impdp导入用户时,实际上通过sqlfile参数可以知道impdp客户端使用了create user xxxxx identified by values '<user$.password value>'来创建用户的。

所以一直以为user$.password的值对于明文一样的密码来说加密后是一样的。

后来遇到在同一个库中,导出用户A,然后同一个库继续导入并使用remap_schema=A:B将A用户改名为B用户后连接报ORA-01017错误。

 

经过查询MOS后,ORA-01017 While Connecting As A User Created With IDENTIFIED BY VALUES Password (文档 ID 279355.1)才发现,对于不同用户但是密码一样的情况,user$.password是不一样的。

如下:

10:25:24 SYS@qadb(490)> create user zkm1 identified by oracle;

User created.

Elapsed: 00:00:00.07
10:25:30 SYS@qadb(490)> create user zkm2 identified by oracle;

User created.

Elapsed: 00:00:00.05
10:25:34 SYS@qadb(490)> select NAME, password from user$ where NAME in ('ZKM1','ZKM2');

NAME            PASSWORD
--------------- -----------------------------------
ZKM1            F1B9117FB233B1EB
ZKM2            21E8C4A68ED58EC6

Elapsed: 00:00:00.00

 

 我一直以为明文密码一样,加密后的也是一样,但实际上不是。

从MOS文档中可以知道,

You can use the encrypted password for the SAME user, but not for another user,
the reason is that before calculating the hash value that is visible as the PASSWORD
in DBA_USERS, Oracle adds the username to the mix and calculates the hash value
on USERNAME||PASSWORD. In 11g the hashing algorithm is changed. See Note 429465.1 for details.

意思是对于同一个用户可以使用加密的密码。因为加密的密码是通过username||password来做hash值的。

也就是实际上user$.password是通过用户和明文密码共同作用产生的。

所以,A用户改为B用户后使用A的user$password旧值就有问题了,表现为连接报错ORA-01017。

 

posted @ 2022-07-18 11:10  PiscesCanon  阅读(543)  评论(0编辑  收藏  举报