代码之家  ›  专栏  ›  技术社区  ›  asmaier

通过python连接到ldap时如何指定basedn?

  •  0
  • asmaier  · 技术社区  · 15 年前

    我想使用特定的basedn连接到使用python ldap的ldap服务器。

    import ldap
    
    baseDN="ou=unit,o=org.c=xx" # doesn't work
    #baseDN="" # works
    host="ldaps://test.org.xx:636"
    userDN="cn=proxyhlrb,ou=services,o=org,c=xx"
    passwd="secret"
    
    server=ldap.initialize(host+"/"+baseDN)
    
    server.bind_s(userDN,passwd,ldap.AUTH_SIMPLE)
    

    这里怎么了?根据文档,ldap.initialize的参数必须是有效的ldap url(根据rfc4516),因此使用主机+basedn应该是有效的。在python ldap中是否有其他方法指定basedn?

    1 回复  |  直到 15 年前
        1
  •  0
  •   Ben    15 年前

    我觉得这个资源对你来说很有趣。它很好地解释了如何将LDAP与Python结合起来。

    http://www.packtpub.com/article/python-ldap-applications-ldap-opearations

    编辑 :您使用的端口是否正确?在PHP中,开发人员主要使用端口389进行LDAP连接、绑定和查询。