Skip Headers
Oracle® Objects for OLE Developer's Guide
11g Release 2 (11.2) for Microsoft Windows

E17727-04
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

ChangePassword (OraSession) Method

Applies To

OraSession Object

Description

Changes the password for a given user.

Usage

OraSession.ChangePassword database_name, user_name, current_password, new_password

Arguments

The arguments for the method are:

Arguments Description
[in] database_name A String representing the Oracle network specifier used when connecting to a database.
[in] user_name A String representing the user for whom the password is changed.
[in] current_password A String representing the current password for the user.
[in] new_password A String representing the new password for whom the user account is set.

Remarks

This method is especially useful when a password has expired. In that case, the OpenDatabase or CreateDatabasePool method could return the following error:

ORA-28001 "the password has expired". 

Examples

Dim OraSession As OraSession 
Dim OraDatabase As OraDatabase 
Dim password as String 
 
'Note: The DBA could expire scott's password by issuing 
'ALTER USER SCOTT PASSWORD EXPIRE  
 
Set OraSession = CreateObject("OracleInProcServer.XOraSession") 
password = "tiger" 
 
On Error GoTo err: 
Set OraDatabase = OraSession.OpenDatabase("ExampleDb", "scott/" & password, 0&)
End 
 
err: 
'Check for password expiration error 
 
If OraSession.LastServerErr = 28001 Then 
    OraSession.ChangePassword "ExampleDb", "scott", password, "newpass" 
    'reset our password variable, then try OpenDatabase again 
    password = "newpass" 
    Resume 
End If 
 
End