ccwhite1
ccwhite1

Reputation: 3775

python validate Oracle username/passwords without using cx_Oracle

I need to validate that user provided data for oracle account information is correct. I tried to use cx_Oracle but the version of OCI.DLL that is on my servers (which I can't upgrade) seems to not be the correct version for cx_Oracle.

How can I validate username/passwords without using cx_Oracle?

Upvotes: 2

Views: 2855

Answers (3)

Martin
Martin

Reputation: 6032

The problem is most likely the version of your cx_Oracle module.

You have to be extremely careful when you install the module, to choose the appropriate version for your oracle installation.

http://cx-oracle.sourceforge.net/

If you can't connect to the database using cx_Oracle, you might have a hard time checking the accuracy of the information

If you have sql*plus installed, you might try to start a process using the subprocess module and check if you can connect, but in my opinion, you might be better of with fixing cx_Oracle

Edit: Meant the subprocess module.

Here is how can you do it with subprocess:

import subprocess

def is_login_valid(user, password, instance):
  output = subprocess.check_output("sqlplus %s/%s@%s" %(user, password, instance))
  return (output.find("ORA-01017") == -1 and output.find("ORA-12154") == -1)

Upvotes: 1

Eli Collins
Eli Collins

Reputation: 8543

If you have access to the username & password hashes through some alternate means that doesn't require cx_Oracle, and simply need to verify the password hashes, the Passlib python library may be able to help. It supports both oracle10g and oracle11g hash formats.

Upvotes: 1

vartec
vartec

Reputation: 134631

If you can't compile cx_Oracle, you have two options:

Upvotes: 3

Related Questions