oracle - 如何在 oracle 中更新 VERIFY_PASSWORD_FUNCTION 以使用户在更改/更改密码之前至少将其密码保留 1 天
问题描述
这是客户需要那里的一项要求,Oracle 用户不会很快更改他的密码,因此他们需要至少保留一天才能更改密码。所以它不能在同一天更改,我们必须更新 VERIFY_PASSWORD_FUNCTION 代码以设置限制最低密码年龄 1 天。
解决方案
在“VERIFY_PASSWORD_FUNCTION”函数中附加以下代码:
CREATE OR REPLACE FUNCTION "SYS"."VERIFY_PASSWORD_FUNCTION"
(username varchar2,
password varchar2,
old_password varchar2)
RETURN boolean IS
last_change sys.user$.ptime%type;
minimum_age number :=1;
userexist integer;
begin
-- Set minimum password age
select count(*) into userexist from sys.user$ where name=username;
if (userexist != 0) then
select ptime into last_change from sys.user$ where name=username;
if sysdate - last_change < minimum_age then
raise_application_error(-20010, 'Password changed too soon');
END IF;
end if;
end;
/
从上面的代码中,您只需附加变量和逻辑。
这是一个测试用例:
SQL> create user TEST11 identified by asdfhe#24HyrE profile USERS;
User Created.
SQL> alter user test11 identified by asdfhe#24HyrWW;
alter user test11 identified by asdfhe#24HyrWW
*
ERROR at line 1:
ORA-28003: password verification for the specified password failed
ORA-20010: Password changed too soon
SQL>
SQL> select name,ptime from user$ where name='TEST11';
NAME PTIME
------------------------------ ---------
TEST11 08-NOV-18
SQL> update user$ set ptime='03-Nov-18' where name='TEST11';
1 row updated.
SQL> select name,ptime from user$ where name='TEST11';
NAME PTIME
------------------------------ ---------
TEST11 03-NOV-18
SQL> commit;
Commit complete.
SQL> alter user test11 identified by asdfhe#24HyrWW;
User altered.
SQL>
由于我们无法在同一天内更改密码,因此我们更新了 ptime 值以验证并再次尝试更改 Test11 用户的密码。
推荐阅读
- laravel - 从 Guzzle6 Payum Paypal Laravel 返回无效异常
- python - 如何正确过滤 django OR 查询
- c# - 如何在不缩放主摄像头的情况下在 Unity for mobile 中创建可缩放的画布图像?
- excel - 通过 ID 码从大型数据库中提取数据
- ldap - 有没有办法剖析 LDAP 消息以将用户名/密码传递给 API?
- heroku - Heroku 抛出“密码不正确或丢失”。尝试安装时出错。本地没有发生
- javascript - Yii 中的自定义类别字段
- r - 如何使用 {highcharter) 创建一个“mapbubble”地图?
- python - Python urllib.request.urlopen 在不断变化的网站上
- javascript - Tampermonkey/GreaseMonkey 自动点击按钮