无法使用python ldap3模块连接到ldap

无法使用python ldap3模块连接到ldap,python,ldap,openldap,python-ldap,ldap3,Python,Ldap,Openldap,Python Ldap,Ldap3,我正在使用联机LDAP测试服务器() 我正在尝试使用python ldap3模块连接到它 这是我的代码: 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 =

我正在使用联机LDAP测试服务器()

我正在尝试使用python ldap3模块连接到它

这是我的代码:

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
当我检查连接时,它是假的

有人能帮我接通吗
提前感谢

如果您将
user='riemann'
更改为
user='uid=riemann,dc=example,dc=com'
,您将获得连接

有关更多信息,请查看文档:

以下内容用于说明如何使用
ldap3
和。