مقدمه:

با استفاده از Profle ها در سطح پایگاه داده اوراکل، می توان برخی از موارد کاربر مانند داشتن idle session و موارد مربوط به Password آن را کنترل کرد. در اوراکل 21c یک قابلیت جدیدی معرفی شده که با آن شما در سطح CDB یک Mandatory Profile ایجاد می کنید که فقط مقدار password_verify_function آن قابل تنظیم خواهد بود به وسیله آن پیچیدگی Password را درسطح همه  PDB ها اعمال خواهید کرد.

در این حالت password_verify_function که به وسیله Mandatory Profile ایجاد می شود بر password_verify_function همه Profile ها مقدم خواهد بود.

نصب و راه اندازی :

یک کاربر با دسترسی DBA در سطح CDB و یک کاربر با همان دسترسی در PDB ایجاد می کنیم.

— CDB

conn sys/SysPassword1@//localhost:1521/cdb1 as sysdba

create user c##my_dba_user identified by DbaPassword1 container=all;

grant create session, dba, pdb_dba to c##my_dba_user container=all;

— PDB

conn sys/SysPassword1@//localhost:1521/pdb1 as sysdba

create user my_dba_user identified by DbaPassword1;

grant create session, dba, pdb_dba to my_dba_user;

Profile کاربر :

در PDB یک تابع برای اعتبارستجی Password می سازیم که کنترل کند طول Password ها بیشتر از 8 حرف باشد.

conn sys/SysPassword1@//localhost:1521/pdb1 as sysdba

create or replace function user_pwd_verify_function (

  username     varchar2,

  password     varchar2,

  old_password varchar2)

return boolean is

begin

  if not ora_complexity_check(password,

                              chars     => 8)

  then

    return(false);

  end if;

  return(true);

end;

/

در ادامه یک Profile  معمولی ایجاد می کنیم واز تابع فوق استفاده می کنیم.

create profile user_profile

  limit password_verify_function user_pwd_verify_function;

alter user my_dba_user profile user_profile;

در ادامه عملکرد این Profile را بررسی می کنیم.

conn my_dba_user/DbaPassword1@//localhost:1521/pdb1

alter user my_dba_user identified by short;

*

ERROR at line 1:

ORA-28003: password verification for the specified password failed

ORA-20000: password length less than 8 characters

alter user my_dba_user identified by DbaPassword1;

User altered.

SQL

Mandatory Profiles

برای این مورد ابتدا یک تابع برای سنجش پیچیدگی Password در سطح CDB ایجاد می کنیم.

conn sys/SysPassword1@//localhost:1521/cdb1 as sysdba

create or replace function c##cdb_pwd_verify_function (

  username     varchar2,

  password     varchar2,

  old_password varchar2)

return boolean is

begin

  if not ora_complexity_check(password,

                              chars     => 16,

                              uppercase => 1,

                              lowercase => 1,

                              digit     => 1,

                              special   => 1)

  then

    return(false);

  end if;

  return(true);

end;

/

در ادامه در سطح CDB یک Mandatory Profile ایجاد می کنیم.

باید به این نکته اشاره کرد که در Mandatory Profile فقط می توان password_verify_function را تنظیم کرد.

create mandatory profile c##cdb_manadatory_profile

  limit

    password_verify_function cdb_pwd_verify_function

      container = all;

دقت کنید در هنگام ساخت باید از کلمه Mandatory استفاده شود.

فعال کردن :

برای فعال کردن این قابلیت باید پارمتر MADATORY_USER_PROFILE در سطح CDB را مقدار دهی کنیم

alter system set mandatory_user_profile=c##cdb_manadatory_profile;

show parameter mandatory_user_profile

NAME                   TYPE   VALUE

———————- —— ————————-

mandatory_user_profile string C##CDB_MANADATORY_PROFILE

SQL>

به مثال های زیر برای ارزیابی توجه کنید.

— CDB

conn c##my_dba_user/DbaPassword1@//localhost:1521/cdb1

show parameter mandatory_user_profile

NAME                                 TYPE        VALUE

———————————— ———– ——————————

mandatory_user_profile               string      C##CDB_MANADATORY_PROFILE

SQL>

alter user c##my_dba_user identified by DbaPassword1 container=all;

*

ERROR at line 1:

ORA-28219: password verification failed for mandatory profile

ORA-20000: password length less than 16 characters

— PDB

conn my_dba_user/DbaPassword1@//localhost:1521/pdb1

show parameter mandatory_user_profile

NAME                                 TYPE        VALUE

———————————— ———– ——————————

mandatory_user_profile               string      C##CDB_MANADATORY_PROFILE

SQL>

alter user my_dba_user identified by DbaPassword1;

*

ERROR at line 1:

ORA-28219: password verification failed for mandatory profile

ORA-20000: password length less than 16 characters

نکته مهم : برای غیر فعال کردن آن کافیه مقدار پارامتر را تغییر دهید. اما این تغییر تا پایگاه داده ریستارت نشود، اعمال نمی گردد .!!!!!

conn sys/SysPassword1@//localhost:1521/cdb1 as sysdba

alter system reset mandatory_user_profile;

show parameter mandatory_user_profile

NAME                   TYPE   VALUE

———————- —— ————————-

mandatory_user_profile string C##CDB_MANADATORY_PROFILE

SQL>

conn / as sysdba

shutdown immediate;

startup;

show parameter mandatory_user_profile

NAME                                 TYPE        VALUE

———————————— ———– ——————————

mandatory_user_profile               string

SQL>

تنظیم پارامتر در سطح PDB

می توان این پارامتر را فقط در سطح PDB تنظیم کرد. به مثال زیر توجه  کنید .

conn sys/SysPassword1@//localhost:1521/pdb1 as sysdba

alter system set mandatory_user_profile=c##cdb_manadatory_profile;

show parameter mandatory_user_profile

NAME                                 TYPE        VALUE

———————————— ———– ——————————

mandatory_user_profile               string      C##CDB_MANADATORY_PROFILE

SQL>

— CDB

conn c##my_dba_user/DbaPassword1@//localhost:1521/cdb1

show parameter mandatory_user_profile

NAME                                 TYPE        VALUE

———————————— ———– ——————————

mandatory_user_profile               string

SQL>

alter user c##my_dba_user identified by DbaPassword1 container=all;

User altered.

SQL>

— PDB

conn my_dba_user/DbaPassword1@//localhost:1521/pdb1

show parameter mandatory_user_profile

NAME                                 TYPE        VALUE

———————————— ———– ——————————

mandatory_user_profile               string      C##CDB_MANADATORY_PROFILE

SQL>

alter user my_dba_user identified by DbaPassword1;

*

ERROR at line 1:

ORA-28219: password verification failed for mandatory profile

ORA-20000: password length less than 16 characters