Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 8

Microsoft Windows [version 10.0.19044.

2251]
(c) Microsoft Corporation. Tous droits réservés.

C:\Windows\system32>set oracle_sid=orcl2

C:\Windows\system32>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Mer. DÚc. 14 11:20:57 2022

Copyright (c) 1982, 2010, Oracle. All rights reserved.

ConnectÚ Ó :
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> CONNECT / AS SYSDBA


ConnectÚ.
SQL> CREATE USER jeff
2 IDENTIFIED BY superman
3 DEFAULT TABLESPACE users
4 QUOTA 1M ON users ;

Utilisateur crÚÚ.

SQL> GRANT connect,resource TO jeff;

Autorisation de privilÞges (GRANT) acceptÚe.

SQL> Rem
SQL> Rem $Header: utlpwdmg.sql 31-aug-2000.11:00:47 nireland Exp $
SQL> Rem
SQL> Rem utlpwdmg.sql
SQL> Rem
SQL> Rem Copyright (c) Oracle Corporation 1996, 2000. All Rights Reserved.
SQL> Rem
SQL> Rem NAME
SQL> Rem utlpwdmg.sql - script for Default Password Resource Limits
SQL> Rem
SQL> Rem DESCRIPTION
SQL> Rem This is a script for enabling the password management features
SQL> Rem by setting the default password resource limits.
SQL> Rem
SQL> Rem NOTES
SQL> Rem This file contains a function for minimum checking of password
SQL> Rem complexity. This is more of a sample function that the customer
SQL> Rem can use to develop the function for actual complexity checks that the
SQL> Rem customer wants to make on the new password.
SQL> Rem
SQL> Rem MODIFIED (MM/DD/YY)
SQL> Rem nireland 08/31/00 - Improve check for username=password. #1390553
SQL> Rem nireland 06/28/00 - Fix null old password test. #1341892
SQL> Rem asurpur 04/17/97 - Fix for bug479763
SQL> Rem asurpur 12/12/96 - Changing the name of password_verify_function
SQL> Rem asurpur 05/30/96 - New script for default password management
SQL> Rem asurpur 05/30/96 - Created
SQL> Rem
SQL>
SQL> -- This script sets the default password resource parameters
SQL> -- This script needs to be run to enable the password features.
SQL> -- However the default resource parameters can be changed based
SQL> -- on the need.
SQL> -- A default password complexity function is also provided.
SQL> -- This function makes the minimum complexity checks like
SQL> -- the minimum length of the password, password not same as the
SQL> -- username, etc. The user may enhance this function according to
SQL> -- the need.
SQL> -- This function must be created in SYS schema.
SQL> -- connect sys/<password> as sysdba before running the script
SQL>
SQL> CREATE OR REPLACE FUNCTION verify_function
2 (username varchar2,
3 password varchar2,
4 old_password varchar2)
5 RETURN boolean IS
6 n boolean;
7 m integer;
8 differ integer;
9 isdigit boolean;
10 ischar boolean;
11 ispunct boolean;
12 digitarray varchar2(20);
13 punctarray varchar2(25);
14 chararray varchar2(52);
15
16 BEGIN
17 digitarray:= '0123456789';
18 chararray:= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
19 punctarray:='!"#$%&()``*+,-/:;<=>?_';
20
21 -- Check if the password is same as the username
22 IF NLS_LOWER(password) = NLS_LOWER(username) THEN
23 raise_application_error(-20001, 'Password same as or similar to user');
24 END IF;
25
26 -- Check for the minimum length of the password
27 IF length(password) < 4 THEN
28 raise_application_error(-20002, 'Password length less than 4');
29 END IF;
30
31 -- Check if the password is too simple. A dictionary of words may be
32 -- maintained and a check may be made so as not to allow the words
33 -- that are too simple for the password.
34 IF NLS_LOWER(password) IN ('welcome', 'database', 'account', 'user',
'password', 'oracle', 'computer', 'abcd') THEN
35 raise_application_error(-20002, 'Password too simple');
36 END IF;
37
38 -- Check if the password contains at least one letter, one digit and one
39 -- punctuation mark.
40 -- 1. Check for the digit
41 isdigit:=FALSE;
42 m := length(password);
43 FOR i IN 1..10 LOOP
44 FOR j IN 1..m LOOP
45 IF substr(password,j,1) = substr(digitarray,i,1) THEN
46 isdigit:=TRUE;
47 GOTO findchar;
48 END IF;
49 END LOOP;
50 END LOOP;
51 IF isdigit = FALSE THEN
52 raise_application_error(-20003, 'Password should contain at least one
digit, one character and one punctuation');
53 END IF;
54 -- 2. Check for the character
55 <<findchar>>
56 ischar:=FALSE;
57 FOR i IN 1..length(chararray) LOOP
58 FOR j IN 1..m LOOP
59 IF substr(password,j,1) = substr(chararray,i,1) THEN
60 ischar:=TRUE;
61 GOTO findpunct;
62 END IF;
63 END LOOP;
64 END LOOP;
65 IF ischar = FALSE THEN
66 raise_application_error(-20003, 'Password should contain at least one \
67 digit, one character and one punctuation');
68 END IF;
69 -- 3. Check for the punctuation
70 <<findpunct>>
71 ispunct:=FALSE;
72 FOR i IN 1..length(punctarray) LOOP
73 FOR j IN 1..m LOOP
74 IF substr(password,j,1) = substr(punctarray,i,1) THEN
75 ispunct:=TRUE;
76 GOTO endsearch;
77 END IF;
78 END LOOP;
79 END LOOP;
80 IF ispunct = FALSE THEN
81 raise_application_error(-20003, 'Password should contain at least one \
82 digit, one character and one punctuation');
83 END IF;
84
85 <<endsearch>>
86 -- Check if the password differs from the previous password by at least
87 -- 3 letters
88 IF old_password IS NOT NULL THEN
89 differ := length(old_password) - length(password);
90
91 IF abs(differ) < 3 THEN
92 IF length(password) < length(old_password) THEN
93 m := length(password);
94 ELSE
95 m := length(old_password);
96 END IF;
97
98 differ := abs(differ);
99 FOR i IN 1..m LOOP
100 IF substr(password,i,1) != substr(old_password,i,1) THEN
101 differ := differ + 1;
102 END IF;
103 END LOOP;
104
105 IF differ < 3 THEN
106 raise_application_error(-20004, 'Password should differ by at \
107 least 3 characters');
108 END IF;
109 END IF;
110 END IF;
111 -- Everything is fine; return TRUE ;
112 RETURN(TRUE);
113 END;
114 /

Fonction crÚÚe.

SQL>
SQL> -- This script alters the default parameters for Password Management
SQL> -- This means that all the users on the system have Password Management
SQL> -- enabled and set to the following values unless another profile is
SQL> -- created with parameter values set to different value or UNLIMITED
SQL> -- is created and assigned to the user.
SQL>
SQL> ALTER PROFILE DEFAULT LIMIT
2 PASSWORD_LIFE_TIME UNLIMITED
3 PASSWORD_GRACE_TIME 10
4 PASSWORD_REUSE_TIME 1800
5 PASSWORD_REUSE_MAX UNLIMITED
6 FAILED_LOGIN_ATTEMPTS 3
7 PASSWORD_LOCK_TIME 1/1440
8 PASSWORD_VERIFY_FUNCTION verify_function;

Profil modifiÚ.

SQL> ALTER USER jeff IDENTIFIED BY jeff;


ALTER USER jeff IDENTIFIED BY jeff
*
ERREUR Ó la ligne 1 :
ORA-28003: Úchec de la vÚrification du mot de passe indiquÚ
ORA-20001: Password same as or similar to user

SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> ALTER USER jeff
2 IDENTIFIED BY super1$;

Utilisateur modifiÚ.

SQL>
SQL>
SQL>
SQL> ALTER PROFILE default LIMIT
2 FAILED_LOGIN_ATTEMPTS 2
3 PASSWORD_LIFE_TIME 30
4 PASSWORD_REUSE_TIME 1/1440
5 PASSWORD_GRACE_TIME 5;

Profil modifiÚ.

SQL>
SQL> SELECT resource_name, limit
2 FROM dba_profiles
3 WHERE profile='DEFAULT'
4 AND resource_type='PASSWORD'
5
SQL>
SQL>
SQL>
SQL> SELECT resource_name, limit
2 FROM dba_profiles
3 WHERE profile='DEFAULT'
4 AND resource_type='PASSWORD';

RESOURCE_NAME LIMIT
-------------------------------- ----------------------------------------
FAILED_LOGIN_ATTEMPTS 2
PASSWORD_LIFE_TIME 30
PASSWORD_REUSE_TIME ,0006
PASSWORD_REUSE_MAX UNLIMITED
PASSWORD_VERIFY_FUNCTION VERIFY_FUNCTION
PASSWORD_LOCK_TIME ,0006
PASSWORD_GRACE_TIME 5

7 ligne(s) sÚlectionnÚe(s).

SQL>
SQL>
SQL>
SQL>
SQL> CONNECT jeff/superman
ERROR:
ORA-01017: invalid username/password; logon denied

Avertissement : vous n'Ûtes plus connectÚ Ó ORACLE.


SQL> CONNECT jeff/super
ERROR:
ORA-01017: invalid username/password; logon denied

SQL> CONNECT jeff/super1$


ERROR:
ORA-28000: the account is locked

SQL> CONNECT / AS SYSDBA


ConnectÚ.
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> SELECT username, account_status
2 FROM dba_users;
USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
SYS OPEN
SYSTEM OPEN
DBSNMP OPEN
SYSMAN OPEN
HR OPEN
SOHA OPEN
JEFF LOCKED(TIMED)
MGMT_VIEW LOCKED
OUTLN EXPIRED & LOCKED
FLOWS_FILES EXPIRED & LOCKED
MDSYS EXPIRED & LOCKED

USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
ORDSYS EXPIRED & LOCKED
EXFSYS EXPIRED & LOCKED
WMSYS EXPIRED & LOCKED
APPQOSSYS EXPIRED & LOCKED
APEX_030200 EXPIRED & LOCKED
OWBSYS_AUDIT EXPIRED & LOCKED
ORDDATA EXPIRED & LOCKED
CTXSYS EXPIRED & LOCKED
ANONYMOUS EXPIRED & LOCKED
XDB EXPIRED & LOCKED
ORDPLUGINS EXPIRED & LOCKED

USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
OWBSYS EXPIRED & LOCKED
SI_INFORMTN_SCHEMA EXPIRED & LOCKED
OLAPSYS EXPIRED & LOCKED
SCOTT EXPIRED & LOCKED
ORACLE_OCM EXPIRED & LOCKED
XS$NULL EXPIRED & LOCKED
BI EXPIRED & LOCKED
PM EXPIRED & LOCKED
MDDATA EXPIRED & LOCKED
IX EXPIRED & LOCKED
SH EXPIRED & LOCKED

USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
DIP EXPIRED & LOCKED
OE EXPIRED & LOCKED
APEX_PUBLIC_USER EXPIRED & LOCKED
SPATIAL_CSW_ADMIN_USR EXPIRED & LOCKED
SPATIAL_WFS_ADMIN_USR EXPIRED & LOCKED

38 ligne(s) sÚlectionnÚe(s).

SQL> ALTER USER jeff


2 ACCOUNT UNLOCK;

Utilisateur modifiÚ.

SQL>
SQL>
SQL> ALTER PROFILE default LIMIT
2 2 FAILED_LOGIN_ATTEMPTS UNLIMITED
3 3 PASSWORD_LIFE_TIME UNLIMITED
4 4 PASSWORD_REUSE_TIME UNLIMITED
5 5 PASSWORD_REUSE_MAX UNLIMITED
6 6 PASSWORD_VERIFY_FUNCTION NULL
7 7 PASSWORD_LOCK_TIME UNLIMITED
8 8 PASSWORD_GRACE_TIME UNLIMITED;
2 FAILED_LOGIN_ATTEMPTS UNLIMITED
*
ERREUR Ó la ligne 2 :
ORA-02376: ressource erronÚe ou redondante

SQL> ALTER PROFILE default LIMIT


2 FAILED_LOGIN_ATTEMPTS UNLIMITED
3 PASSWORD_LIFE_TIME UNLIMITED
4 PASSWORD_REUSE_TIME UNLIMITED
5 PASSWORD_REUSE_MAX UNLIMITED
6 PASSWORD_VERIFY_FUNCTION NULL
7 PASSWORD_LOCK_TIME UNLIMITED
8 PASSWORD_GRACE_TIME UNLIMITED;

Profil modifiÚ.

SQL> CONNECT jeff/superman


ERROR:
ORA-01017: invalid username/password; logon denied

Avertissement : vous n'Ûtes plus connectÚ Ó ORACLE.


SQL> CONNECT jeff/super
ERROR:
ORA-01017: invalid username/password; logon denied

SQL> CONNECT jeff/super1$


ConnectÚ.
SQL> CONNECT system/manager
ERROR:
ORA-01017: invalid username/password; logon denied

Avertissement : vous n'Ûtes plus connectÚ Ó ORACLE.


SQL> CONNECT system/123
ConnectÚ.
SQL> CREATE USER bob
2 IDENTIFIED BY crusader
3 DEFAULT TABLESPACE USERS
4 TEMPORARY TABLESPACE temp
5 QUOTA 1M ON USERS
6 QUOTA 1M ON INDX;
CREATE USER bob
*
ERREUR Ó la ligne 1 :
ORA-00959: le tablespace 'INDX' n'existe pas
SQL>
SQL> CREATE USER bob
2 IDENTIFIED BY crusader
3 DEFAULT TABLESPACE USERS
4 TEMPORARY TABLESPACE temp
5 QUOTA 1M ON USERS;

Utilisateur crÚÚ.

SQL> @$HOME/STUDENT/LABS/lab15_01.sql
SP2-0310: impossible d'ouvrir le fichier "$HOME/STUDENT/LABS/lab15_01.sql"
SQL>

You might also like