简体   繁体   中英

Unable to connect to ldap using python ldap3 module

I am using Online LDAP Test Server( https://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/ )

I am trying to connect to it using python ldap3 module.

This is my code:

import ldap3
user = 'riemann'
password = 'password'
server = ldap3.Server('ldap.forumsys.com', port=389)
connection = ldap3.Connection(server, user=user, password=password)
connection.bind()
conn = connection.search(search_base='ou=mathematicians,dc=example,dc=com', search_filter='(&(objectClass=user)(userPrincipalName='+user+'))', attributes='*')

print conn

When I check the conn it is False .

Can someone help me in getting the connection Thanks in advance

if you change user='riemann' to user='uid=riemann,dc=example,dc=com' you'll get a connection

for more information check the docs: http://ldap3.readthedocs.io/bind.html#simple-bind

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM