Oracle密码复杂度
sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on 星期一 3月 25 22:53:24 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> @?/rdbms/admin/utlpwdmg.sql
转自:http://blog.itpub.net/23135684/viewspace-757083/
或者自定义脚本
-----------------------------------脚本如下--------------------------------------------
CREATE OR REPLACE FUNCTION PASSWORD_VERIFY_FUNCTION
(
username varchar2,
password varchar2,
old_password varchar2)
RETURN boolean IS
n boolean;
m integer;
differ integer;
isdigit boolean;
ischar boolean;
ispunct boolean;
db_name varchar2(40);
digitarray varchar2(20);
punctarray varchar2(25);
specialarray varchar2(14);
chararray varchar2(52);
i_char varchar2(10);
simple_password varchar2(10);
reverse_user varchar2(32);
BEGIN
digitarray:= '0123456789';
chararray:= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
specialarray:= '~!@#$%^&*()_<>';
-- 校验密码长度至少为8位
IF length(password) < 8 THEN
raise_application_error(-20001, 'Password length less than 8');
END IF;
-- 校验密码是否和用户名相同
IF NLS_LOWER(password) = NLS_LOWER(username) THEN
raise_application_error(-20002, 'Password same as or similar to user');
END IF;
FOR i IN 1..100 LOOP
i_char := to_char(i);
if NLS_LOWER(username)|| i_char = NLS_LOWER(password) THEN
raise_application_error(-20005, 'Password same as or similar to user name ');
END IF;
END LOOP;
-- 校验密码是不是用户名的反序
FOR i in REVERSE 1..length(username) LOOP
reverse_user := reverse_user || substr(username, i, 1);
END LOOP;
IF NLS_LOWER(password) = NLS_LOWER(reverse_user) THEN
raise_application_error(-20003, 'Password same as username reversed');
END IF;
-- 校验密码是否是服务名
select name into db_name from sys.v$database;
if NLS_LOWER(db_name) = NLS_LOWER(password) THEN
raise_application_error(-20004, 'Password same as or similar to server name');
END IF;
FOR i IN 1..100 LOOP
i_char := to_char(i);
if NLS_LOWER(db_name)|| i_char = NLS_LOWER(password) THEN
raise_application_error(-20005, 'Password same as or similar to server name ');
END IF;
END LOOP;
-- 检查用户密码是否过于简单,
-- 检查密码是否有列表中的关键字
-- 是否存在弱口令
IF NLS_LOWER(password) IN ('welcome1', 'database1', 'account1', 'user1234', 'password1', 'oracle123', 'computer1', 'abcdefg1', 'change_on_install') THEN
raise_application_error(-20006, 'Password too simple');
END IF;
-- 检查密码是否为oracle
simple_password := 'oracle';
FOR i IN 1..100 LOOP
i_char := to_char(i);
if simple_password || i_char = NLS_LOWER(password) THEN
raise_application_error(-20007, 'Password too simple ');
END IF;
END LOOP;
-- 检验密码至少包含至少一个字母,一个数字 ,一个特殊字符
-- 1. 校验数字
isdigit:=FALSE;
m := length(password);
FOR i IN 1..10 LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(digitarray,i,1) THEN
isdigit:=TRUE;
GOTO findchar;
END IF;
END LOOP;
END LOOP;
IF isdigit = FALSE THEN
raise_application_error(-20008, 'Password must contain at least one digit, one character');
END IF;
-- 2. 检验字符
<>
ischar:=FALSE;
FOR i IN 1..length(chararray) LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(chararray,i,1) THEN
ischar:=TRUE;
GOTO endsearch;
END IF;
END LOOP;
END LOOP;
IF ischar = FALSE THEN
raise_application_error(-20009, 'Password must contain at least one \
digit, and one character');
END IF;
-- 3. 检验特殊字符
<>
ischar:=FALSE;
FOR i IN 1..length(specialarray) LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(specialarray,i,1) THEN
ischar:=TRUE;
GOTO endsearch;
END IF;
END LOOP;
END LOOP;
IF ischar = FALSE THEN
raise_application_error(-20009, 'Password must contain at least one special_char');
END IF;
<>
--检验密码和上一个密码至少有三个不同字符
--
IF old_password IS NOT NULL THEN
differ := length(old_password) - length(password);
differ := abs(differ);
IF differ < 3 THEN
IF length(password) < length(old_password) THEN
m := length(password);
ELSE
m := length(old_password);
END IF;
FOR i IN 1..m LOOP
IF substr(password,i,1) != substr(old_password,i,1) THEN
differ := differ + 1;
END IF;
END LOOP;
IF differ < 3 THEN
raise_application_error(-20011, 'Password should differ from the \
old password by at least 3 characters');
END IF;
END IF;
END IF;
-- Everything is fine; return TRUE ;
RETURN(TRUE);
END;
CREATE OR REPLACE FUNCTION PASSWORD_VERIFY_FUNCTION
(
username varchar2,
password varchar2,
old_password varchar2)
RETURN boolean IS
n boolean;
m integer;
differ integer;
isdigit boolean;
ischar boolean;
ispunct boolean;
db_name varchar2(40);
digitarray varchar2(20);
punctarray varchar2(25);
specialarray varchar2(14);
chararray varchar2(52);
i_char varchar2(10);
simple_password varchar2(10);
reverse_user varchar2(32);
BEGIN
digitarray:= '0123456789';
chararray:= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
specialarray:= '~!@#$%^&*()_<>';
-- 校验密码长度至少为8位
IF length(password) < 8 THEN
raise_application_error(-20001, 'Password length less than 8');
END IF;
-- 校验密码是否和用户名相同
IF NLS_LOWER(password) = NLS_LOWER(username) THEN
raise_application_error(-20002, 'Password same as or similar to user');
END IF;
FOR i IN 1..100 LOOP
i_char := to_char(i);
if NLS_LOWER(username)|| i_char = NLS_LOWER(password) THEN
raise_application_error(-20005, 'Password same as or similar to user name ');
END IF;
END LOOP;
-- 校验密码是不是用户名的反序
FOR i in REVERSE 1..length(username) LOOP
reverse_user := reverse_user || substr(username, i, 1);
END LOOP;
IF NLS_LOWER(password) = NLS_LOWER(reverse_user) THEN
raise_application_error(-20003, 'Password same as username reversed');
END IF;
-- 校验密码是否是服务名
select name into db_name from sys.v$database;
if NLS_LOWER(db_name) = NLS_LOWER(password) THEN
raise_application_error(-20004, 'Password same as or similar to server name');
END IF;
FOR i IN 1..100 LOOP
i_char := to_char(i);
if NLS_LOWER(db_name)|| i_char = NLS_LOWER(password) THEN
raise_application_error(-20005, 'Password same as or similar to server name ');
END IF;
END LOOP;
-- 检查用户密码是否过于简单,
-- 检查密码是否有列表中的关键字
-- 是否存在弱口令
IF NLS_LOWER(password) IN ('welcome1', 'database1', 'account1', 'user1234', 'password1', 'oracle123', 'computer1', 'abcdefg1', 'change_on_install') THEN
raise_application_error(-20006, 'Password too simple');
END IF;
-- 检查密码是否为oracle
simple_password := 'oracle';
FOR i IN 1..100 LOOP
i_char := to_char(i);
if simple_password || i_char = NLS_LOWER(password) THEN
raise_application_error(-20007, 'Password too simple ');
END IF;
END LOOP;
-- 检验密码至少包含至少一个字母,一个数字 ,一个特殊字符
-- 1. 校验数字
isdigit:=FALSE;
m := length(password);
FOR i IN 1..10 LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(digitarray,i,1) THEN
isdigit:=TRUE;
GOTO findchar;
END IF;
END LOOP;
END LOOP;
IF isdigit = FALSE THEN
raise_application_error(-20008, 'Password must contain at least one digit, one character');
END IF;
-- 2. 检验字符
<
ischar:=FALSE;
FOR i IN 1..length(chararray) LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(chararray,i,1) THEN
ischar:=TRUE;
GOTO endsearch;
END IF;
END LOOP;
END LOOP;
IF ischar = FALSE THEN
raise_application_error(-20009, 'Password must contain at least one \
digit, and one character');
END IF;
-- 3. 检验特殊字符
<
ischar:=FALSE;
FOR i IN 1..length(specialarray) LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(specialarray,i,1) THEN
ischar:=TRUE;
GOTO endsearch;
END IF;
END LOOP;
END LOOP;
IF ischar = FALSE THEN
raise_application_error(-20009, 'Password must contain at least one special_char');
END IF;
<
--检验密码和上一个密码至少有三个不同字符
--
IF old_password IS NOT NULL THEN
differ := length(old_password) - length(password);
differ := abs(differ);
IF differ < 3 THEN
IF length(password) < length(old_password) THEN
m := length(password);
ELSE
m := length(old_password);
END IF;
FOR i IN 1..m LOOP
IF substr(password,i,1) != substr(old_password,i,1) THEN
differ := differ + 1;
END IF;
END LOOP;
IF differ < 3 THEN
raise_application_error(-20011, 'Password should differ from the \
old password by at least 3 characters');
END IF;
END IF;
END IF;
-- Everything is fine; return TRUE ;
RETURN(TRUE);
END;
在测试环境学习oracle,出现用户密码过期的问题,更改密码提示验证未通过,因为为测试环境,为方便期间,不需要经常修改密码,在此发现profile的使用方法,记录如下。
SQL> SELECT * FROM dba_profiles ;
查看用户所属的 profile ,一般为DEFAULT
SQL>select * from dba_profiles where resource_type='PASSWORD';
SQL> alter user lh identified by lh;
alter user lh identified by lh
ORA-28003: password verification for the specified password failed
ORA-20001: Password same as or similar to user
取消密码管理:
SQL>alter profile DEFAULT limit unlimited;
如:
SQL>alter profile DEFAULT limit password_reuse_time unlimited;
停止密码检验函数:
SQL>alter profile DEFAULT limit password_verify_function null;
创建 用户 专用 profile:
CREATE PROFILE test LIMIT
SESSIONS_PER_USER UNLIMITED
CPU_PER_SESSION UNLIMITED
CPU_PER_CALL 3000
CONNECT_TIME 45
LOGICAL_READS_PER_SESSION DEFAULT
LOGICAL_READS_PER_CALL 1000
PRIVATE_SGA 15K
COMPOSITE_LIMIT 5000000;
如需更改:
SQL>alter profile test limit PASSWORD_LIFE_TIME 60 ;
更改用户profile
SQL>alter user scott profile test;
****************************************************************
Oracle数据库用户密码过期处理
1、sqlplus 用户/密码@数据库服务 as sysdba;
2、select username,profile from dba_users;
3、select * from dba_profiles s where s.profile='default' and resource_name='password_life_time';
4、alter profile default limit password_life_time unlimited;
如果用户已经被锁定,则执行5,否则不用执行5;
5、alter user 用户 identified by 密码 account unlock;
//////////////////////////////////////
/*查看用户所属的 profile,一般为DEFAULT*/
SELECT * FROM dba_profiles;
select * from dba_profiles where resource_type='PASSWORD' and profile=upper('PROFILE1');
/*停止密码检验函数:*/
alter profile PROFILE1 limit PASSWORD_VERIFY_FUNCTION null;
alter user yufeng profile DEFAULT;
alter profile PROFILE1 limit PASSWORD_LIFE_TIME 60 ;
alter profile PROFILE1 limit password_life_time unlimited;
/*如果用户已经被锁定,则执行下面SQL,否则不用执行;*/
alter user 用户 identified by 密码 account unlock;
***********************************************************************************************
=》Oracle密码复杂度设置(Oracle_Password_Complexity)
一、Oracle_Password_Complexity:
SQL> alter system set resource_limit = true;
SQL> @ $ORACLE_HOME/RDBMS/ADMIN/utlpwdmg.sql → [verify_function|verify_function_11G]
SQL> alter profile default limit password_verify_function verify_function;
# 取消Oracle密码复杂度检查:
SQL> alter profile default limit password_verify_function null;
SQL> SELECT profile,resource_type,resource_name,limit FROM dba_profiles WHERE resource_type='PASSWORD' AND profile='DEFAULT';
1.FAILED_LOGIN_ATTEMPTS: 用户在登录尝试失败n次后被锁定。
2.PASSWORD_LOCK_TIME: 登录尝试失败达到指定次数,用户锁定时长,以“Day”为单位。
3.PASSWORD_LIFE_TIME: 用户口令的生命周期。
4.PASSWORD_GRACE_TIME: 表示用户口令使用时间超过其生命周期后,可以延续使用的天数,并且可延续时间内登录会有相应口令即将过期的提示。
5.PASSWORD_REUSE_TIME: 指定了口令不能重用前的天数。
6.PASSWORD_REUSE_MAX: 在达到PASSWORD_REUSE_TIME指定时间后,要再次使用同一口令前必须改变的次数。
如:PASSWORD_REUSE_TIME=30,PASSWORD_REUSE_MAX=10,用户可以在30天以后重用该口令,要求口令必须被改变超过10次。
7.PASSWORD_VERIFY_FUNCTION: Oracle允许将复杂的PL/SQL密码验证脚本做为参数传递给PASSWORD_VERIFY_FUNCTION。并且其自己提供了一个默认的脚本,但是用户可以创建自己的验证规则或使用第三方软件验证。
8.Password Verify Function:
When you create a password verify function for verifying the user password, this function can verify the following password characteristics:
1.The minimum number of characters for the password.
2.The characters that the password must contain, such as when a password should contain a specific number of numeric, alphabetic or special characters.
3.Whether or not the password can be the same as the username.Whether or not the new password can be similar to the previous password.
Oracle 11g数据库密码区分大小写的设置 → SEC_CASE_SENSITIVE_LOGON = TRUE.
分享名称:Oracle密码复杂度
文章地址:http://scjbc.cn/article/poejpg.html