Python, ldap3 and Apache Directory Studio

Asked

Viewed 152 times

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 Python’s ldap3 module, I can’t do Bind on the server. The answer is always a mistake.

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

ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);

Someone would have some light?

Thank you

1 answer

0


Using the library https://github.com/pyldap/pyldap is quite simple.

Follow a basic example of use:

>>> 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 with this you can adapt your needs.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.