Python, ldap3 and Apache Directory Studio

2

I have a local LDAP server created in Apache Directory Studio, running on port 10389.

When I connect using php, I can do searches normally, but when I try to connect using the ldap3 module in Python, I can not do Bind on the server. The answer is always a mistake.

I use the same credentials, both in PHP and in Python. The only configuration I could not do in Python and that I use in PHP is:

ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);

Would anyone have any light?

Thank you

    
asked by anonymous 14.08.2017 / 13:38

1 answer

0

Using the link library is quite simple.

Here is a basic example of usage:

>>> import ldap
>>> con = ldap.initialize('ldap://localhost:389', bytes_mode=False)
>>> con.simple_bind_s('login', 'secret_password')
>>> results = con.search_s('ou=people,dc=example,dc=org', ldap.SCOPE_SUBTREE, "(cn=Raphaël)")
>>> results
[
    ("cn=Raphaël,ou=people,dc=example,dc=org", {
        'cn': [b'Rapha\xc3\xabl'],
        'sn': [b'Barrois'],
    }),
]

I believe that you can adapt your needs accordingly.

    
17.08.2017 / 13:25