Skip to content

Instantly share code, notes, and snippets.

@zodman
Created April 10, 2012 23:19
Show Gist options
  • Save zodman/2355530 to your computer and use it in GitHub Desktop.
Save zodman/2355530 to your computer and use it in GitHub Desktop.
ldap conection test
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