成功连接到Windows Server上运行的Active Directory使用Python-dap:
使用10.15.120.250 IP地址import ldap
url = 'ldap://10.15.120.250'
user = 'myusername@post.ad'
password = 'pass'
conn = ldap.initialize(url)
conn.protocol_version = 3
conn.set_option(ldap.OPT_REFERRALS, 0)
conn.simple_bind_s(user, password)
我想继续找到带有姓氏"约翰逊"的用户。
如何实现它?
姓氏通常存储在" sn"(姓氏(字段中。http://www.zytrax.com/books/ldap/ape/
conn.search_ext('cn=base,dc=example,dc=com', ldap.SCOPE_SUBTREE, '(sn=Johnson)')
名字在" fivedname"
中conn.search_ext('cn=base,dc=example,dc=com', ldap.SCOPE_SUBTREE, '(givenName=Johnson)')