开发者

How to specify a baseDN when connecting to LDAP via python?

开发者 https://www.devze.com 2022-12-11 15:39 出处:网络
I want to connect to a ldap server with python-ldap using a specific baseDN. import ldap baseDN=\"ou=unit,o=org.c=xx\" # doesn\'t work

I want to connect to a ldap server with python-ldap using a specific baseDN.

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)

What is wrong here? According to the documentation the argument of ldap.initialize must be a valid LDAP URL according to RFC4516 and therefore using a host+baseDN should work. Is there another开发者_如何转开发 way to specify a baseDN in python-ldap?


I think this resource would be interesting for you. It nicely explains how to combine LDAP with Python.

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

Edit: is the port you are using correct? In PHP, developers mainly use port 389 for LDAP connects, bindings and queries.

0

精彩评论

暂无评论...
验证码 换一张
取 消