[python-ldap] LDAP bind with Windows credentials

Steffen Frömer steffen.froemer at gns-systems.de
Fri Feb 22 11:27:58 CET 2013


Hello,

i am new to python ldap and i want to bind against active directory  
with my windows credentials.

Is there a proper way to do this?

This solution works for me, but I don't want to enter my password to  
make a ldap request.


     ad = ldap.initialize("ldap://server", trace_level=2)
     ad.set_option(ldap.OPT_PROTOCOL_VERSION, ldap.VERSION3)
     ad.set_option(ldap.OPT_REFERRALS, 0)

     ad.bind_s('testuser at EXAMPLE.com','s3cr3t')

     result_id = ad.search("dc=example,dc=com", ldap.SCOPE_SUBTREE,  
"cn=testuser", None)
     result_type, result_data = ad.result(result_id, 0)
     pprint.pprint(result_data)


Regards, Steffen


More information about the python-ldap mailing list