簡體   English   中英

無法使用python ldap3模塊連接到ldap

[英]Unable to connect to ldap using python ldap3 module

我正在使用在線LDAP測試服務器( https://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/

我正在嘗試使用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

當我檢查conn時,它為False

有人可以幫助我獲得連接嗎?謝謝

如果將user='riemann'更改為user='uid=riemann,dc=example,dc=com'您將獲得連接

有關更多信息,請檢查文檔: http : //ldap3.readthedocs.io/bind.html#simple-bind

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM