Page 1 of 1

OCI_INVALID_HANDLE TOraSession.ChangePassword

Posted: Mon 19 Apr 2010 21:38
by AdamKG
Hello,

I try to provide in my application possibility to change password if user is in grace period. But geting OCI_INVALID_HANDLE

Steps to reproduce:
drop TOraSession on form set ConnectString to user with grace period and OnInfoMessage event to

Code: Select all

procedure TForm1.OraSession1InfoMessage(Sender: TObject; Error: EOraError);
begin
  if Error.ErrorCode=28002 then
    OraSession1.ChangePassword('test');
end;
When orasession1.connect is done on user who has grace period the password is changed but an error is rised as well.

ODAC 6.90.0.57 for RAD Studio 2007

Posted: Tue 20 Apr 2010 11:09
by bork
Hello

Unfortunately we cannot reproduce your issue. Please tell us the version of Oracle client and server you are using.

Posted: Tue 20 Apr 2010 11:19
by AdamKG
OCI: Version 11.1.0.1.0 (not loaded)
DLL: c:\oracle_x32\product\11.1.0\client_1\BIN\oci.dll

Oracle Database 11g Release 11.1.0.6.0 - 64bit Production

Posted: Wed 21 Apr 2010 12:13
by bork
Hello

The problem is that when you are handling the OnInfoMessage event, connection is not fully established and a part of OCI variables is initialized and another part is not initialized. If you are trying to change password at this moment then you will get the OCI_INVALID_HANDLE error.

You should set a variable in the OnInfoMessage event:

procedure TForm1.OraSession1InfoMessage(Sender: TObject; Error: EOraError);
begin
if Error.ErrorCode=28002 then
FPasswordExpired := true;
end;

And change password in the OnAfterConnect event when connection is established:

procedure TForm1.OraSession1AfterConnect(Sender: TObject);
begin
if FPasswordExpired then
OraSession1.ChangePassword('new_password');
end;