How to catch Oracle password grace period?
How to catch Oracle password grace period?
There is some posibility to catch ORA-28002 error (pasword grace period)?
If you mean that you need to specify whether the error is ORA-28002 or something else, this can be made using the Code property of the OracleException class. This property returns an integer specifying the error type according to the Oracle error classification. For instance, the ORA-28002 error will generate an OracleException with Code = 28002.
If you encounter problems with raising the exception for the ORA-28002 error, please give us a more detailed description of the issue and the steps we should follow to reproduce it.
If you encounter problems with raising the exception for the ORA-28002 error, please give us a more detailed description of the issue and the steps we should follow to reproduce it.
OracleConnection con = new OracleConnection(connectionString);
try{con.Open();con.Close();message = "OK";}
catch(OracleException ex){
if (ex.Code == 28001){message = "EXPIRED";}
else if(ex.Code == 28002){message = "GRACE";}
else{ message = ex.Code.ToString();}
}
If password is expired (Oracle throws ORA-28001) then that code works as expected, if password is in grace period (must be thrown ORA-28002 error) there is no exception.
OracleDataProvider version: v2.0.50727
try{con.Open();con.Close();message = "OK";}
catch(OracleException ex){
if (ex.Code == 28001){message = "EXPIRED";}
else if(ex.Code == 28002){message = "GRACE";}
else{ message = ex.Code.ToString();}
}
If password is expired (Oracle throws ORA-28001) then that code works as expected, if password is in grace period (must be thrown ORA-28002 error) there is no exception.
OracleDataProvider version: v2.0.50727
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
We have investigated the problem. As ORA-28002 is an informational message and actually not an error, it throws no exception.
We have added the functionality to trace the message, it will be available in the next build. ORA-28002 will invoke the OracleConnection.InfoMessage event, and the Code property of the corresponding OracleInfoMessageEventArgs object will contain the message code (i.e. 28002).
We have added the functionality to trace the message, it will be available in the next build. ORA-28002 will invoke the OracleConnection.InfoMessage event, and the Code property of the corresponding OracleInfoMessageEventArgs object will contain the message code (i.e. 28002).