My Oracle Support Banner

Using OCIPasswordChange() to Change Password (Doc ID 99457.1)

Last updated on JUNE 27, 2023

Applies to:

Oracle Database - Enterprise Edition - Version and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Gen 1 Exadata Cloud at Customer (Oracle Exadata Database Cloud Machine) - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.


This article contains a program that demonstrates how to use the OCIPasswordChange() function to log on to a database and change a user's password at the same time.  This allows the user to make a connection, even if their existing password has currently expired, i.e. attempts to connect are giving:

  ORA-28001: the password has expired 

NOTE: If OCIPasswordChange is being used to change the password and log on at the same time then e.g. OCIServerAttach must have been successfully called to establish the physical connection first.  OCIPasswordChange only creates the session over the current connection.  If an attempt was made to connect via OCILogon but this failed due to an expired password then OCIPasswordChange will subsequently fail with OCI_INVALID_HANDLE as the service context handle will not be properly initialised.  OCIPasswordChange can therefore only be used with OCILogon when the log on has been successful. 


To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.