如何在PHP中捕获oracle宽限期消息?
我在 PHP 应用程序中使用 Oracle 数据库。
用户尝试连接到 PHP 应用程序。他的密码已过期,但其用户个人资料的宽限期不为空,因此他仍然可以连接到应用程序。
我想做的是认识到该用户应该更改他的密码并向他显示一条消息。
我尝试过使用 oci_error()
,但它没有返回任何内容,因为使用该用户连接到数据库没有失败。
我想捕获 ORA-28001 (和 ORA-28002)
不幸的是,我无法对数据库本身的结构进行任何更改(添加额外的表或额外的字段)。
I use an Oracle database in a PHP application.
A user tries to connect to the PHP application. His password has expired, but the grace period for his user's profile isn't null, so he can still connect to the application.
What I would like to do is recognize that this user should change his password and display him a message.
I've tried with oci_error()
, but it doesn't return anything as there were no failure in connecting to the database with this user.
I would like to catch ORA-28001 (and ORA-28002)
Unfortunately, I can't do any change of structure in the database itself (add extra table or extra field).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
扩展 Narf 的答案,这对我来说适用于 Oracle 11.2
宽限期内密码的输出是:
Expanding Narf's answer, this works for me with Oracle 11.2
Its output for a password in the grace period is:
请参阅 OCILogon 问题 - Oracle 密码过期非常相似的问题,有解决方案。应该可以在当前的 php 版本中工作。也非常类似于 宽限期内的 OCILogon - ORA-28002on SO
See OCILogon problem - Oracle password expiry a very similar problem, with a solution. Should work in the current php version. Also very similar to OCILogon during Grace Period - ORA-28002on SO
尝试在执行
oci_connect()
时启用警告,然后使用自定义错误处理程序捕获它们(确保在连接时不会忽略带有 @ 的错误)。这可能需要您还调整 php.ini 中的 oci 扩展设置。Try enabling warnings when you execute
oci_connect()
and then catching them with a custom error handler(make sure you're not ignoring errors with @ when connecting). This could require you to tweak also the oci extension settings in php.ini.