I was writing a utility to unlock a user account when the user knew their password. The unlocking part was easy (assuming the ID your are connecting as has permissions to unlock an account):
ALTER USER Scott ACCOUNT UNLOCK;
My problem was trying to match the password the user entered with the one that is stored in the database – I only wanted to unlock a password if the user was really the user (i.e. knew their user ID and knew their password). But I found a fantastic script at http://www.petefinnigan.com/testpwd.sql that did just what I needed.
Once I ran the script to load the function, I just needed to call the function like so:
select testpwd('Scott', 'bla') from dual;
This will return “Y” for the right password and “N” for an incorrect password. Super slick.