Downloading a file with LDAP authentication

1k Views Asked by At

I'm trying to find a way to download a CSV from a network URI (not web) that requires LDAP authentication. I have a service account made for this, but I'm not able to find a working solution:

conn = ldap.open("10.41.10.10:389") #I've tried different URIs
conn.simple_bind_s('[email protected]', 'password')       
call = open(r'\\fserv03\reports\gps_List.csv')

Is there a better way to do this?

Updated: Got Python-LDAP to work for my 64 bit install after downloading Python-LDAP to work, I downloaded python_ldap-2.4.28-cp27-cp27m-win_amd64 and running the pip install on it.

1

There are 1 best solutions below

0
On

I was able to get this to work with the following (using Python-LDAP library):

try:
    l = ldap.initialize('ldap://LDAP SERVER HERE')
    l.protocol_version = ldap.VERSION2
    username = "cn=USER, o=example.com"
    password = 'PASSWORD HERE'
    l.simple_bind(username, password)
except ldap.LDAPError, e:
    print e