一、目的
二、DEFAULT PROFILE
三、PROFILE的划分
四、管理一个PROFILE
五、资源限制条件
SQL> show parameter resource_limitNAME TYPE VALUE------------------------------------ ----------- ------------------------------resource_limit boolean FALSESQL> alter system set resource_limit=true;系统已更改。SQL> show parameter resource_limit;NAME TYPE VALUE------------------------------------ ----------- ------------------------------resource_limit boolean TRUE
六、语法
CREATE PROFILE profile LIMIT { resource_parameters | password_parameters }[ resource_parameters | password_parameters ]... ;resource_parameters:{{ SESSIONS_PER_USER | CPU_PER_SESSION | CPU_PER_CALL | CONNECT_TIME | IDLE_TIME | LOGICAL_READS_PER_SESSION | LOGICAL_READS_PER_CALL | COMPOSITE_LIMIT } { integer | UNLIMITED | DEFAULT }| PRIVATE_SGA { integer [ K | M ] | UNLIMITED | DEFAULT }}password_parameters :{{ FAILED_LOGIN_ATTEMPTS | PASSWORD_LIFE_TIME | PASSWORD_REUSE_TIME | PASSWORD_REUSE_MAX | PASSWORD_LOCK_TIME | PASSWORD_GRACE_TIME } { expr | UNLIMITED | DEFAULT }| PASSWORD_VERIFY_FUNCTION { function | NULL | DEFAULT }}
七、语法解释


八、举例
-- ALTER PROFILE DEFAULT LIMIT-- PASSWORD_LIFE_TIME 180-- PASSWORD_GRACE_TIME 7-- PASSWORD_REUSE_TIME UNLIMITED-- PASSWORD_REUSE_MAX UNLIMITED-- FAILED_LOGIN_ATTEMPTS 10-- PASSWORD_LOCK_TIME 1-- PASSWORD_VERIFY_FUNCTION verify_function_11G;
SQL> @?/rdbms/admin/utlpwdmg.sql函数已创建。配置文件已更改函数已创建。
CREATE PROFILE wlc_profile LIMITSESSIONS_PER_USER UNLIMITEDCPU_PER_SESSION UNLIMITEDCPU_PER_CALL UNLIMITEDCONNECT_TIME UNLIMITEDIDLE_TIME 600LOGICAL_READS_PER_SESSION UNLIMITEDLOGICAL_READS_PER_CALL UNLIMITEDCOMPOSITE_LIMIT UNLIMITEDPRIVATE_SGA UNLIMITEDFAILED_LOGIN_ATTEMPTS 10PASSWORD_LIFE_TIME 180PASSWORD_REUSE_TIME 30PASSWORD_REUSE_MAX 10PASSWORD_LOCK_TIME 1PASSWORD_GRACE_TIME 10PASSWORD_VERIFY_FUNCTION verify_function;
SQL> alter user test profile wlc_profile;SQL> alter user test profile default;
SQL> alter profile wlc_profile limit 参数 新值; (对于当前连接修改不生效)alter profile wlc_profile limit PASSWORD_LIFE_TIME UNLIMITED;alter profile wlc_profile limit PASSWORD_GRACE_TIME UNLIMITED;alter profile wlc_profile limit PASSWORD_VERIFY_FUNCTION NULL;
SQL> drop profile wlc_profile (cascade);
SQL> select profile from dba_users where username='TEST';
SQL> select * from SYS.DBA_PROFILES;SQL> select * from SYS.USER_RESOURCE_LIMITS;
SQL> create user test identified by test profile reader_profile;create user test identified by test profile reader_profile*ERROR at line 1:ORA-28003: password verification for the specified password failedORA-20001: Password same as or similar to userSQL> create user test identified by test1234 profile reader_profile;create user test identified by test1234 profile reader_profile*ERROR at line 1:ORA-28003: password verification for the specified password failedORA-20003: Password should contain at least one \digit, one character and one punctuationSQL> create user test identified by "test_123!" profile reader_profile;User created.SQL> select username,profile from dba_users where username='TEST';USERNAME PROFILE------------------------------ ------------------------------TEST READER_PROFILESQL> alter user test identified by "test";alter user test identified by "test"*ERROR at line 1:ORA-28003: password verification for the specified password failedORA-20001: Password same as or similar to user
$ORACLE_HOME/rdbms/admin/utlpwdmg.sql:
RemRem $Header: utlpwdmg.sql 02-aug-2006.08:18:05 asurpur Exp $RemRem utlpwdmg.sqlRemRem Copyright (c) 2006, Oracle. All rights reserved.RemRem NAMERem utlpwdmg.sql - script for Default Password Resource LimitsRemRem DESCRIPTIONRem This is a script for enabling the password management featuresRem by setting the default password resource limits.RemRem NOTESRem This file contains a function for minimum checking of passwordRem complexity. This is more of a sample function that the customerRem can use to develop the function for actual complexity checks that theRem customer wants to make on the new password.RemRem MODIFIED (MM/DD/YY)Rem asurpur 05/30/06 - fix - 5246666 beef up password complexity checkRem nireland 08/31/00 - Improve check for username=password. #1390553Rem nireland 06/28/00 - Fix null old password test. #1341892Rem asurpur 04/17/97 - Fix for bug479763Rem asurpur 12/12/96 - Changing the name of password_verify_functionRem asurpur 05/30/96 - New script for default password managementRem asurpur 05/30/96 - CreatedRem-- This script sets the default password resource parameters-- This script needs to be run to enable the password features.-- However the default resource parameters can be changed based-- on the need.-- A default password complexity function is also provided.-- This function makes the minimum complexity checks like-- the minimum length of the password, password not same as the-- username, etc. The user may enhance this function according to-- the need.-- This function must be created in SYS schema.-- connect sys/as sysdba before running the scriptCREATE OR REPLACE FUNCTION verify_function_11G(username varchar2,password varchar2,old_password varchar2)RETURN boolean ISn boolean;m integer;differ integer;isdigit boolean;ischar boolean;ispunct boolean;db_name varchar2(40);digitarray varchar2(20);punctarray varchar2(25);chararray varchar2(52);i_char varchar2(10);simple_password varchar2(10);reverse_user varchar2(32);BEGINdigitarray:= '0123456789';chararray:= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';-- Check for the minimum length of the passwordIF length(password) < 8 THENraise_application_error(-20001, 'Password length less than 8');END IF;-- Check if the password is same as the username or username(1-100)IF NLS_LOWER(password) = NLS_LOWER(username) THENraise_application_error(-20002, 'Password same as or similar to user');END IF;FOR i IN 1..100 LOOPi_char := to_char(i);if NLS_LOWER(username)|| i_char = NLS_LOWER(password) THENraise_application_error(-20005, 'Password same as or similar to user name ');END IF;END LOOP;-- Check if the password is same as the username reversedFOR i in REVERSE 1..length(username) LOOPreverse_user := reverse_user || substr(username, i, 1);END LOOP;IF NLS_LOWER(password) = NLS_LOWER(reverse_user) THENraise_application_error(-20003, 'Password same as username reversed');END IF;-- Check if the password is the same as server name and or servername(1-100)select name into db_name from sys.v$database;if NLS_LOWER(db_name) = NLS_LOWER(password) THENraise_application_error(-20004, 'Password same as or similar to server name');END IF;FOR i IN 1..100 LOOPi_char := to_char(i);if NLS_LOWER(db_name)|| i_char = NLS_LOWER(password) THENraise_application_error(-20005, 'Password same as or similar to server name ');END IF;END LOOP;-- Check if the password is too simple. A dictionary of words may be-- maintained and a check may be made so as not to allow the words-- that are too simple for the password.IF NLS_LOWER(password) IN ('welcome1', 'database1', 'account1', 'user1234', 'password1', 'oracle123', 'computer1', 'abcdefg1', 'change_on_install') THENraise_application_error(-20006, 'Password too simple');END IF;-- Check if the password is the same as oracle (1-100)simple_password := 'oracle';FOR i IN 1..100 LOOPi_char := to_char(i);if simple_password || i_char = NLS_LOWER(password) THENraise_application_error(-20007, 'Password too simple ');END IF;END LOOP;-- Check if the password contains at least one letter, one digit-- 1. Check for the digitisdigit:=FALSE;m := length(password);FOR i IN 1..10 LOOPFOR j IN 1..m LOOPIF substr(password,j,1) = substr(digitarray,i,1) THENisdigit:=TRUE;GOTO findchar;END IF;END LOOP;END LOOP;IF isdigit = FALSE THENraise_application_error(-20008, 'Password must contain at least one digit, one character');END IF;-- 2. Check for the character<>ischar:=FALSE;FOR i IN 1..length(chararray) LOOPFOR j IN 1..m LOOPIF substr(password,j,1) = substr(chararray,i,1) THENischar:=TRUE;GOTO endsearch;END IF;END LOOP;END LOOP;IF ischar = FALSE THENraise_application_error(-20009, 'Password must contain at least one \digit, and one character');END IF;<>-- Check if the password differs from the previous password by at least-- 3 lettersIF old_password IS NOT NULL THENdiffer := length(old_password) - length(password);differ := abs(differ);IF differ < 3 THENIF length(password) < length(old_password) THENm := length(password);ELSEm := length(old_password);END IF;FOR i IN 1..m LOOPIF substr(password,i,1) != substr(old_password,i,1) THENdiffer := differ + 1;END IF;END LOOP;IF differ < 3 THENraise_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;/-- This script alters the default parameters for Password Management-- This means that all the users on the system have Password Management-- enabled and set to the following values unless another profile is-- created with parameter values set to different value or UNLIMITED-- is created and assigned to the user.-- ALTER PROFILE DEFAULT LIMIT-- PASSWORD_LIFE_TIME 180-- PASSWORD_GRACE_TIME 7-- PASSWORD_REUSE_TIME UNLIMITED-- PASSWORD_REUSE_MAX UNLIMITED-- FAILED_LOGIN_ATTEMPTS 10-- PASSWORD_LOCK_TIME 1-- PASSWORD_VERIFY_FUNCTION verify_function_11G;-- Below is the older version of the script-- This script sets the default password resource parameters-- This script needs to be run to enable the password features.-- However the default resource parameters can be changed based-- on the need.-- A default password complexity function is also provided.-- This function makes the minimum complexity checks like-- the minimum length of the password, password not same as the-- username, etc. The user may enhance this function according to-- the need.-- This function must be created in SYS schema.-- connect sys/as sysdba before running the scriptCREATE OR REPLACE FUNCTION verify_function(username varchar2,password varchar2,old_password varchar2)RETURN boolean ISn boolean;m integer;differ integer;isdigit boolean;ischar boolean;ispunct boolean;digitarray varchar2(20);punctarray varchar2(25);chararray varchar2(52);BEGINdigitarray:= '0123456789';chararray:= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';punctarray:='!"#$%&()``*+,-/:;<=>?_';-- Check if the password is same as the usernameIF NLS_LOWER(password) = NLS_LOWER(username) THENraise_application_error(-20001, 'Password same as or similar to user');END IF;-- Check for the minimum length of the passwordIF length(password) < 4 THENraise_application_error(-20002, 'Password length less than 4');END IF;-- Check if the password is too simple. A dictionary of words may be-- maintained and a check may be made so as not to allow the words-- that are too simple for the password.IF NLS_LOWER(password) IN ('welcome', 'database', 'account', 'user', 'password', 'oracle', 'computer', 'abcd') THENraise_application_error(-20002, 'Password too simple');END IF;-- Check if the password contains at least one letter, one digit and one-- punctuation mark.-- 1. Check for the digitisdigit:=FALSE;m := length(password);FOR i IN 1..10 LOOPFOR j IN 1..m LOOPIF substr(password,j,1) = substr(digitarray,i,1) THENisdigit:=TRUE;GOTO findchar;END IF;END LOOP;END LOOP;IF isdigit = FALSE THENraise_application_error(-20003, 'Password should contain at least one digit, one character and one punctuation');END IF;-- 2. Check for the character<>ischar:=FALSE;FOR i IN 1..length(chararray) LOOPFOR j IN 1..m LOOPIF substr(password,j,1) = substr(chararray,i,1) THENischar:=TRUE;GOTO findpunct;END IF;END LOOP;END LOOP;IF ischar = FALSE THENraise_application_error(-20003, 'Password should contain at least one \digit, one character and one punctuation');END IF;-- 3. Check for the punctuation<>ispunct:=FALSE;FOR i IN 1..length(punctarray) LOOPFOR j IN 1..m LOOPIF substr(password,j,1) = substr(punctarray,i,1) THENispunct:=TRUE;GOTO endsearch;END IF;END LOOP;END LOOP;IF ispunct = FALSE THENraise_application_error(-20003, 'Password should contain at least one \digit, one character and one punctuation');END IF;<>-- Check if the password differs from the previous password by at least-- 3 lettersIF old_password IS NOT NULL THENdiffer := length(old_password) - length(password);IF abs(differ) < 3 THENIF length(password) < length(old_password) THENm := length(password);ELSEm := length(old_password);END IF;differ := abs(differ);FOR i IN 1..m LOOPIF substr(password,i,1) != substr(old_password,i,1) THENdiffer := differ + 1;END IF;END LOOP;IF differ < 3 THENraise_application_error(-20004, 'Password should differ by at \least 3 characters');END IF;END IF;END IF;-- Everything is fine; return TRUE ;RETURN(TRUE);END;/-- This script alters the default parameters for Password Management-- This means that all the users on the system have Password Management-- enabled and set to the following values unless another profile is-- created with parameter values set to different value or UNLIMITED-- is created and assigned to the user.-- Enable this if you want older version of the Password Profile parameters-- ALTER PROFILE DEFAULT LIMIT-- PASSWORD_LIFE_TIME 60-- PASSWORD_GRACE_TIME 10-- PASSWORD_REUSE_TIME 1800-- PASSWORD_REUSE_MAX UNLIMITED-- FAILED_LOGIN_ATTEMPTS 3-- PASSWORD_LOCK_TIME 1/1440-- PASSWORD_VERIFY_FUNCTION verify_function;
文章转载自DBA小记,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




