防止业务自身通过Oracle客户端或第三方客户端工具修改密码,造成其他应用连接错误,防止数据库因密码延时验证,出现Library cache lock等待事件。
适用版本:Oracle 11.2.0.4及以后版本
创建用户hfxf并授予权限。
SYS@cdb19c >create user hfxf identified by Oracle_123;User created.SYS@cdb19c >grant connect,resource to hfxf;Grant succeeded.使用业务用户hfxf登录,尝试修改自身密码
[oracle@db19do01 ~]$ sqlplus hfxf/Oracle_123@hrpdbSQL*Plus: Release 19.0.0.0.0 - Production on Mon Sep 19 21:57:08 2022Version 19.3.0.0.0Copyright (c) 1982, 2019, Oracle. All rights reserved.Connected to:Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - ProductionVersion 19.3.0.0.0HFXF@hrpdb >show userUSER is "HFXF"HFXF@hrpdb >alter user hfxf identified by Oracle_456;User altered.HFXF@hrpdb >HFXF@hrpdb >passwordChanging password for HFXFOld password:New password:Retype new password:Password changedHFXF@hrpdb >业务用户hfxf可以修改自身密码创建密码验证的函数
SYS@cdb19c >CREATE OR REPLACE FUNCTION verify_function_false(username varchar2,password varchar2, old_password varchar2) RETURN boolean IS BEGIN if user not in ('SYS','SYSTEM') then -- customize this to allow any particular user by adding those users in this list of users. RETURN(FALSE); elsereturn true; end if; END;/ Function created.
创建profile并使用函数verify_function_false
SYS@cdb19c >CREATE PROFILE NO_CHANGE_PWD LIMIT PASSWORD_VERIFY_FUNCTION verify_function_false;Profile created.SYS@cdb19c >修改业务用户profile
SYS@cdb19c >alter user hfxf profile NO_CHANGE_PWD;User altered.SYS@cdb19c >进行验证,业务用户hfxf已经不能修改自己密码
[oracle@db19do01 ~]$ sqlplus hfxf/Oracle_789@hrpdbSQL*Plus: Release 19.0.0.0.0 - Production on Mon Sep 19 22:06:54 2022Version 19.3.0.0.0Copyright (c) 1982, 2019, Oracle. All rights reserved.Last Successful login time: Mon Sep 19 2022 22:06:19 +08:00Connected to:Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - ProductionVersion 19.3.0.0.0HFXF@hrpdb >alter user hfxf identified by Oracle_123;alter user hfxf identified by Oracle_123*ERROR at line 1:ORA-28221: REPLACE not specifiedHFXF@hrpdb >passwordChanging password for HFXFOld password:New password:Retype new password:ERROR:ORA-28003: password verification for the specified password failedPassword unchangedHFXF@hrpdb >-the end-
最后修改时间:2022-09-20 14:32:05
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




