【问题标题】:LDAP filter with ldap3 library not working带有 ldap3 库的 LDAP 过滤器不起作用
【发布时间】: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 用户。

【问题讨论】:

    标签: python ldap ldap3


    【解决方案1】:

    好的,找到了解决方案。必须像这样在连接中提供凭据:

    with ldap3.Connection(server, user="myLdapUser", password="myLdapPassword", auto_bind=True)
    

    【讨论】:

      猜你喜欢
      • 2016-08-04
      • 2013-09-24
      • 1970-01-01
      • 2019-02-06
      • 2015-08-01
      • 1970-01-01
      • 2018-04-21
      • 2018-02-14
      • 1970-01-01
      相关资源
      最近更新 更多