关于python3.x:python-ldap查询用户

30次阅读

共计 453 个字符,预计需要花费 2 分钟才能阅读完成。

LDAP_SERVER_POOL = "ldap://10.x1.x0.x1:389"

ADMIN_DN = "CN=it_ldap,OU=ServiceAccount,DC=xxxxhu,DC=sh"    ##ldap 治理用户
ADMIN_PASSWORD = "uxxzP"
SEARCH_BASE = "OU=xixoxxhu-sh,DC=xxxshu,DC=sh"



import ldap
ldapconn = ldap.initialize(LDAP_SERVER_POOL)
print(ldapconn.simple_bind_s(ADMIN_DN, ADMIN_PASSWORD))
searchScope = ldap.SCOPE_SUBTREE
#searchFilter = 'sAMAccountName=lixxxx'
searchFilter = 'cn= 李 xx'
print(ldapconn.search_s(SEARCH_BASE, searchScope, searchFilter, None))

呈现 (97, [], 1, []) 代表连贯胜利

正文完
 0