I created a user in an Oracle 11 database for Tiago
(http://uk.linkedin.com/pub/tiago-vasconcelos/0/652/494), a colleague of mine. Then I E-mailed the password to him and expired it. I do this quite often as it forces the user to change his password when he next logs in, so that he can set it to a value known only to him. He phoned me back soon after, saying that he was unable to alter the password so I decided to investigate. I found that if you connect to an Oracle 11 database using an Oracle 11 client, you can change your own password with the alter user and password commands. You can also reset your password if it has expired. This is demonstrated in the example below, which I ran on a Solaris server:
TEST11 > sqlplus system@test11
SQL*Plus: Release 11.1.0.6.0 - Production on Tue Sep 20 14:58:16 2011
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> grant create session to andrew
2 identified by andrew
3 /
Grant succeeded.
SQL> conn andrew/andrew@test11
Connected.
SQL> alter user andrew identified by andrew1
2 /
User altered.
SQL> conn andrew/andrew1@test11
Connected.
SQL> password
Changing password for ANDREW
Old password:
New password:
Retype new password:
Password changed
SQL> conn andrew/andrew2@test11
Connected.
SQL> conn system@test11
Enter password:
Connected.
SQL> alter user andrew password expire
2 /
User altered.
SQL> conn andrew/andrew2@test11
ERROR:
ORA-28001: the password has expired
Changing password for andrew
New password:
Retype new password:
Password changed
Connected.
SQL> conn andrew/andrew3@test11
Connected.
SQL>
However,
if you try to do this using an Oracle 10 client (connected to an Oracle 11 database), the final step, i.e.
resetting your password after it has expired, does not work. The example below illustrates this. I ran it on a Windows Vista client:
SQL*Plus: Release 10.2.0.4.0 - Production on Tue Sep 20 15:08:37 2011
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> conn system@test11
Enter password: *********
Connected.
SQL> grant create session to andrew
2 identified by andrew
3 /
Grant succeeded.
SQL> conn andrew/andrew@test11
Connected.
SQL> alter user andrew identified by andrew1;
User altered.
SQL> conn andrew/andrew1@test11
Connected.
SQL> password
Changing password for ANDREW
Old password: *******
New password: *******
Retype new password: *******
Password changed
SQL> conn andrew/andrew2@test11
Connected.
SQL> conn system@test11
Enter password: *********
Connected.
SQL> alter user andrew password expire
2 /
User altered.
SQL> conn andrew/andrew2@test11
ERROR:
ORA-28001: the password has expired
Changing password for andrew
New password: ********
Retype new password: ********
ERROR:
ORA-01017: invalid username/password; logon denied
Password unchanged
Warning: You are no longer connected to ORACLE.
SQL>