首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否可以用pythonldap3连接到eDirectory?

是否可以用pythonldap3连接到eDirectory?
EN

Stack Overflow用户
提问于 2015-04-08 20:45:10
回答 1查看 657关注 0票数 1

我正在尝试使用python连接到eDirectory。它并不像使用python连接到活动目录那么容易,所以我想知道这是否可能。我目前正在运行python3.4

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-10 06:19:58

我是ldap3的作者,我使用eDirectory来测试库。

只需尝试以下代码:

代码语言:javascript
复制
from ldap3 import Server, Connection, ALL, SUBTREE
server = Server('your_server_name', get_info=ALL)  # don't user get_info if you don't need info on the server and the schema
connection = Connection(server, 'your_user_name_dn', 'your_password')
connection.bind()
if connection.search('your_search_base','(objectClass=*)', SUBTREE, attributes = ['cn', 'objectClass', 'your_attribute'])
    for entry in connection.entries:
        print(entry.entry_get_dn())
        print(entry.cn, entry.objectClass, entry.your_attribute)
connection.unbind()

如果需要安全连接,只需将服务器定义更改为:

代码语言:javascript
复制
server = Server('your_server_name', get_info=ALL, use_tls=True)  # default tls configuration on port 636

而且,https://ldap3.readthedocs.org/en/latest/quicktour.html文档中的任何示例都应该使用eDirectory。

再见,乔瓦尼

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29525025

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档