Last active
December 27, 2015 16:19
-
-
Save asafge/7354124 to your computer and use it in GitHub Desktop.
ldap - bind and query a directory with python-ldap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ldap | |
# Initialize and bind | |
con = ldap.initialize('ldap://10.0.0.23') | |
dn = "cn=test,dc=example,dc=com" | |
pw = "Pass1" | |
con.simple_bind_s(dn, pw) | |
# Run a query against the directory | |
baseDN = "cn=users,dc=example,dc=com" | |
searchScope = ldap.SCOPE_SUBTREE | |
retrieveAttributes = None | |
searchFilter = "cn=*asaf*" | |
res = con.search_s(baseDN, searchScope, searchFilter, retrieveAttributes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment