0

My problem is pretty complicated. I managed to create a simple python script to connect to the oracle database by the ldap connection but I keep wondering if this is well done, because i can't connect properly. Login, password, LDAP server, basedn works correctly because it works correctly in oracle sql developer app.

From Oracle SQL Developer

import ldap
#from ldap import open

if __name__ == "__main__":
    ldap_server="xxxxxxxx.com:389:636"
    username = "xxxxxx"
    password= "xxxxxxx"

    user_dn = "uid="+username+",dc=na,dc=xx,dc=com"

    base_dn = "cn=xxxxxxx,dc=na,dc=xx,dc=com"
    connect = ldap.open(ldap_server)
    search_filter = "uid="+username
    try:
        connect.bind_s(user_dn,password)
        result = connect.search_s(base_dn,ldap.SCOPE_SUBTREE,search_filter)

        connect.unbind_s()
        print(result)
    except ldap.LDAPError:
        connect.unbind_s()
        print ("authentication error")

Can anyone help me because I'm losing my mind :( ?

aliciavika
  • 87
  • 8
  • Surely you need a DB driver, e.g. cx_Oracle, or am I missing what you want to do with the DB? Steps to use LDAP are in https://stackoverflow.com/questions/31994159/how-do-you-connect-to-an-ldap-server-using-node-oracledb/32151099#32151099 – Christopher Jones Jan 10 '20 at 01:26
  • Thank you for your answer. I'd like to call up some selects from database. But i work on windows 10, Could you show me some simple steps to that? – aliciavika Jan 11 '20 at 11:44
  • Check the cx_Oracle [documentation](https://cx-oracle.readthedocs.io/en/latest/index.html) and review the [samples](https://github.com/oracle/python-cx_Oracle/tree/master/samples). – Christopher Jones Jan 11 '20 at 21:39

0 Answers0