You will always come across situations where RCA is more important than the solution.
A similar request knocked me last week where the user needs to
know what process or who (person) locked the id.
There are several ways to achieve this. In this blog, I would describe by setting up audit method.
- Use a trigger to capture additional information
- Set an event in the "init.ora" parameter file
- Audit unsuccessful logins
- Use SQLNET Tracing to gather detailed information
For rest of the methods please follow “Finding the source of
failed login attempts. (Doc ID 352389.1)”
Before we dive in, a quick recap..
Status# of an account in oracle database is from 0 to 10 are the.
Notice that 3 and 7 are missing. Why?
The logic behind it is that you would never end up with status EXPIRED EXPIRED (GRACE) or EXPIRED EXPIRED (GRACE) LOCKED (TIMED), which doesn’t makes sense However, you can have status# 5, 6, 9 & 10. If you sum up 4+1 you would get status#=5 i.e. EXPIRED & LOCKED (TIMED), similarly others.
What do they mean in real life?
Account status:- OPEN - Account is open and accessible
- EXPIRED - Account is expired. Access denied.
- EXPIRED (GRACE) - Account is expired but still accessible. You will be given grace period to change the password to keep the account status to OPEN.
- LOCKED (TIMED) - Account is locked due to unsuccessful login attempts
- LOCKED - Account is locked by the admin.
- EXPIRED & LOCKED(TIMED)
- EXPIRED(GRACE) & LOCKED(TIMED)
- EXPIRED & LOCKED
- EXPIRED(GRACE) & LOCKED
What parameters govern them?
failed_login_attempts - This is the number of failed login attempts before locking the Oracle user account.
password_grace_time - This is the grace period after
the password_life_time limit is exceeded. In this example after 60 days of
password life time 10 days grace period will be allowed to reset the password
of the account .
password_life_time - This is how long an
existing password is valid.
password_lock_time - This is the number of
days that must pass after an account is locked before it is
unlocked. It specifies how long to lock the account after the failed
login attempts is met.
password_reuse_time - This parameter specifies a
time limit before a previous password can be re-entered. To allow unlimited use
of previously used passwords, set password_reuse_time to
UNLIMITED.
password_verify_function - This allows you to specify the name of a custom password verification function. Example PASSWORD_VERIFY_STRONG function uploaded in GitHub.
password_reuse_max - This is the number of times that
you may reuse a password and is intended to prevent repeating password cycles.
If you reset the password to same value then you defy the purpose. However,
real world is not ideal and you would want to reset the same password for
application schema due to hard-coding, bad policies etc.
SQL> select * from dba_profiles
where profile='USERS' and resource_type='PASSWORD';
----------
------------------------------ ------------------------ ------------------------------
USERS FAILED_LOGIN_ATTEMPTS PASSWORD 5 NO
USERS PASSWORD_LIFE_TIME PASSWORD 60 NO
USERS PASSWORD_REUSE_TIME PASSWORD 60 NO
USERS PASSWORD_REUSE_MAX PASSWORD 5 NO
USERS PASSWORD_VERIFY_FUNCTION PASSWORD PASSWORD_VERIFY_STRONG NO
USERS PASSWORD_LOCK_TIME PASSWORD UNLIMITED NO
USERS PASSWORD_GRACE_TIME PASSWORD 10 NO
alter user nava identified by
"Password00!"
*
ERROR at line 1:
ORA-28007: the password cannot be
reused
FAILED_LOGIN_ATTEMPTS UNLIMITED
PASSWORD_LIFE_TIME UNLIMITED
PASSWORD_REUSE_TIME UNLIMITED
PASSWORD_REUSE_MAX UNLIMITED
PASSWORD_VERIFY_FUNCTION NULL
PASSWORD_LOCK_TIME UNLIMITED
PASSWORD_GRACE_TIME UNLIMITED;
How to trace suspect logins that have
failed with ora-1017 ?
- Check the status from dba_users.
---------- ---------------
NAVA LOCKED
Unsuccessful connect attempts can be a nuisance, especially when a password management policy is in place that has a limit on failed_login_attempts and cause the ora-28000 "the account is locked" error.
Remember unlocking
is not what they are looking for, they want to know who/what process is locking
the ID .
SQL> select username,
account_status from dba_users where username ='NAVA';
---------- ---------------
NAVA LOCKED(TIMED)
An account never get locked due to
password expiration. That is reason we need to screen the accounts in regular
audit cycle and take action such as lock explicitly.
Before the account is actually locked you can inspect the number of failed login attempts so far by checking the USER$.LCOUNT column. I have tried 5 times so LCOUNT is 5.
SQL> select ctime,ltime,ptime,lcount from user$
where name='NAVA';
--------------- ---------------
--------------- ----------
13-AUG-20 13-AUG-20 13-AUG-20 5
---------- ---------------
NAVA Open
SQL> select username,
account_status from dba_users where username ='NAVA';
---------- ---------------
NAVA LOCKED(TIMED)
- Let us find the culprit and enable the audit.
------------------------------------ --------------------------------- --------------
audit_trail string DB
os_username,
userhost,
trunc(timestamp),
count(*) failed_logins
from dba_audit_trail
where returncode=1017 and --1017 is
invalid username/password
username='NAVA' and
timestamp > sysdate -7
group by
username,os_username,userhost, client_id,trunc(timestamp);
---------- --------------------
------------- --------------- -------------
NAVA 771690 LT095983 13-AUG-20 6
SQL>



Comments
Post a Comment