ldap
#!/bin/env python import sys import ldap ldapconn = ldap.initialize('ldap://domain.adserve.com') print ldapconn print ldapconn.simple_bind('cn=xixi,dc=adserve,dc=com', '123456Zz') ldapconn.protocal_version = ldap.VERSION3 searchScope = ldap.SCOPE_SUBTREE retrieveAttributes = None searchFilter = 'cn=' + 'xixi' ldap_result_id=ldapconn.search('dc=adserve,dc=com', searchScope, searchFilter, retrieveAttributes) print ldap_result_id result_type, result_data = ldapconn.result(ldap_result_id, 0) if result_type == ldap.RES_SEARCH_ENTRY: a=result_data[0][0] ldapconn.simple_bind_s(a,'123456Zz') ldapconn.passwd_s(a,'123456Zz','123456Zyy') ldapconn.unbind()