开发者

python validate Oracle username/passwords without using cx_Oracle

I need to validate that user provided data for oracle acc开发者_运维问答ount 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?


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

  • use ODBC (for example PyODBC);
  • use subprocess to interact with sqlplus.


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.


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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜