【发布时间】:2020-07-03 10:46:46
【问题描述】:
我正在尝试使用以下 Python 代码 sn-p 从 LDAP 中检索用户信息。 我正在使用 ldap3 库来查询 LDAP。
def searchUser():
server = Server('myLdapServer:389')
try:
with Connection(server) as conn:
conn.search('ou=xuser,ou=xxx,o=com', '(attribute=cn=user,ou=yuser,ou=xxx,o=com)', attributes=['*'])
for entry in connection.entries:
print(entry)
except:
return 'error in ldap search'
不幸的是,即使当我将 Ldap-Base 和 Ldap-Filter 输入到 Softerra Ldap-Browser 时,我也没有得到任何结果。我在 Softerra-Browser 和代码中使用同一个 Ldap 用户。
【问题讨论】: