ORA-28040 error when changing expired password in Direct Mode

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
VadimShvarts
Posts: 34
Joined: Mon 22 Dec 2008 09:03

ORA-28040 error when changing expired password in Direct Mode

Post by VadimShvarts » Thu 09 Oct 2014 06:15

ODAC v9.4.12
Oracle Database 12.1.0.1.0

I use OnError event of TOraSession object for handle ORA-28001 error and call TOraSession.ChangePassword

When click "OCI" button and enter oratest1/111 -> "OCI Connected"
When click "Direct" button and enter oratest2/111 -> "ORA-28040: No matching authentication protocol"

project1.sql

Code: Select all

create user oratest1 identified by "111" password expire default tablespace USERS temporary tablespace TEMP;
create user oratest2 identified by "111" password expire default tablespace USERS temporary tablespace TEMP;

grant connect to oratest1, oratest2;
unit1.dfm

Code: Select all

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 300
  ClientWidth = 635
  Color = clBtnFace
  ParentFont = True
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 64
    Top = 112
    Width = 75
    Height = 25
    Caption = 'OCI'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Button2: TButton
    Left = 168
    Top = 112
    Width = 75
    Height = 25
    Caption = 'Direct'
    TabOrder = 1
    OnClick = Button2Click
  end
  object OraSession1: TOraSession
    Username = 'ORATEST1'
    Server = 'TEST'
    OnError = OraSession1Error
    Left = 96
    Top = 16
  end
  object OraSession2: TOraSession
    Options.Direct = True
    Username = 'ORATEST2'
    Server = 'test:1521:TEST'
    OnError = OraSession2Error
    Left = 176
    Top = 16
  end
end
unit1.pas

Code: Select all

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, OraError, OraCall, Data.DB, DBAccess,
  Ora, Vcl.StdCtrls, OdacVcl;

type
  TForm1 = class(TForm)
    OraSession1: TOraSession;
    OraSession2: TOraSession;
    Button1: TButton;
    Button2: TButton;
    procedure OraSession2Error(Sender: TObject; E: EDAError; var Fail: Boolean);
    procedure OraSession1Error(Sender: TObject; E: EDAError; var Fail: Boolean);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
 OraSession1.Connected := True;
 ShowMessage('OCI Connected');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 OraSession2.Connected := True;
 ShowMessage('Direct Connected');
end;

procedure TForm1.OraSession1Error(Sender: TObject; E: EDAError;
  var Fail: Boolean);
begin
 if (E is EOraError) and (EOraError(E).ErrorCode = 28001) then
  begin
   Fail := False;
   OraSession1.ChangePassword('222');
  end;
end;

procedure TForm1.OraSession2Error(Sender: TObject; E: EDAError;
  var Fail: Boolean);
begin
 if (E is EOraError) and (EOraError(E).ErrorCode = 28001) then
  begin
   Fail := False;
   OraSession2.ChangePassword('222');
  end;
end;

end.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: ORA-28040 error when changing expired password in Direct Mode

Post by AlexP » Thu 09 Oct 2014 09:19

Hello,

The specified error occurs most likely due to explicit protocol version restriction in the sqlnet.ora file (check availability of Direct connection using active account). Currently, password change is not supported in Direct mode for Oracle 12c. We will try to add this capability in of the next versions.

Post Reply