python - 无法使用 python ldap3 模块连接到 ldap
问题描述
我正在使用在线 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
推荐阅读
- java - 在 DocDoku 中加载示例数据时出错
- java - Android 应用程序中的后台位置更新。(用于实时位置跟踪)
- r - R:如何停止在绘图图表上将百分比四舍五入到小数点后 0 位?
- reactjs - 我正在尝试运行命令 make start。但我收到以下错误
- reactjs - 做出反应。循环功能,不知道如何停止。在函数中映射和获取
- javascript - 如何使用 ID 而不是类添加或删除?
- c# - R中基于命令行参数的操作
- components - AEM 未发布页面在发布实例上仍然可见
- python - 为什么我不能在 Python 中打开 .h5 文件?
- android - 安装应用程序时颤动无法识别Android设备