I have got oracle User Password Expiry date using,
Select Expiry_date from USER_USERS;
I want to throw a warning message when Password is about to expire.
Currently my password is not expiring soon. I want to change the Expiry date to prior date, So that I can test my code.
My user account password should be about to Expire. i.e. I want to get ORA-28002
ERROR.
I tried using
alter user XYZ password expire;
This sets my user ACCOUNT_STATUS
to EXPIRED
state but I want it to be in EXPIRED(GRACE)
status.
Please suggest any possible method.
You have to create a new user profile (or alter an existing one) like this:
CREATE PROFILE SHORT_LIFE_PROFILE LIMIT
PASSWORD_LIFE_TIME 1/24/60/60 --> = 1 second
PASSWORD_GRACE_TIME 1/24; --> = 1 hour
ALTER USER rdj7 PROFILE SHORT_LIFE_PROFILE;
In order to get ACCOUNT_STATUS = EXPIRED(GRACE)
you have to logon with this user, otherwise the status does not change.
C:\>sqlplus rdj7/*****@yourDB
SQL*Plus: Release 11.2.0.1.0 Production on Fri Mar 10 10:09:29 2017
Copyright (c) 1982, 2010, Oracle. All rights reserved.
ERROR:
ORA-28002: the password will expire within 0 days
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning option
SQL>
Then you should see it:
SELECT ACCOUNT_STATUS
FROM DBA_USERS
WHERE USERNAME = 'RDJ7';
ACCOUNT_STATUS
--------------------------------
EXPIRED(GRACE)
1 row selected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With