从win客户端操作用python-ldap大规模的导入用户
主要参考文章https://www.cnblogs.com/littlehb/p/9379851.html
先用交互界面进行原型测试
>>> import hashlib
>>> hashlib.md5("ysk").hexdigest()
'958c6b03f7b874c20c91ce2ee7b3a950'
>>> import binascii
>>> import base64
>>> base64.b64encode(binascii.a2b_hex('958c6b03f7b874c20c91ce2ee7b3a950'))
'lYxrA/e4dMIMkc4u57OpUA=='
>>> def hash_md5(data):
... md = hashlib.md5()
... md.update(str(data))
... a=md.digest()
... b=base64.b64encode(a)
... return b
...
>>> hash_md5('ysk')
'lYxrA/e4dMIMkc4u57OpUA=='
>>> import ldap,ldap.modlist
>>> l=ldap.initialize('ldap://10.16.97.210:389')
>>> l.protocal_version =ldap.VERSION3
>>> l.simple_bind('cn=admin,dc=mydebian210,dc=mydomain,dc=net','secret_password')
>>> addDN='ui