要连接的用户的DN:uid=root,ou=People,dc=demo,dc=com
baseDN:dc=demo,dc=com
10.10.16.14上安装了openldap
代码:
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
import ldap
if __name__ == '__main__':
ldapPath = "ldap://10.10.16.14"
baseDn = "dc=demo,dc=com"
ldapUser = "root"
ldapPasswd = "1"
l = ldap.initialize(ldapPath)
# Set LDAP protocol version used
l.protocol_version = ldap.VERSION3
l.simple_bind_s(ldapUser,ldapPasswd)
print "bind success"
运行后报这个:
找不到原因,最后使用用户的dn进行连接