Matching a password in the Oracle database

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.

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: