Created
April 10, 2012 23:19
-
-
Save zodman/2355530 to your computer and use it in GitHub Desktop.
ldap conection test
This file contains hidden or 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 | |
import pprint | |
# tomado de | |
# http://www.grotan.com/ldap/python-ldap-samples.html#search | |
# conectamos al active directory | |
l = ldap.open("10.0.0.203") | |
#hacemos un bind | |
# cn =test objecto | |
# cn=Users que pertene a los usuarios | |
#dc = dominio | |
l.simple_bind("cn=test,cn=Users, dc=ad,dc=interalia","zxc") | |
# vemos el resultado del bind | |
pprint.pprint(l.result()) | |
#buscamos al usuario que tenga la palabra *a* | |
#en el grupo de usuarios del dominio | |
l.search("cn=Users,dc=ad,dc=interalia",ldap.SCOPE_SUBTREE,"cn=*a*") | |
# vemos el resulstado | |
pprint.pprint(l.result()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment