Skip to content

Instantly share code, notes, and snippets.

@dnozay
Created May 13, 2015 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnozay/9accf51947968e30fab5 to your computer and use it in GitHub Desktop.
Save dnozay/9accf51947968e30fab5 to your computer and use it in GitHub Desktop.
python-ldap simple test script
#!/usr/bin/env python
import ldap, sys
LDAP_SERVER = 'ldaps://ldap.example.com:636'
LDAP_BASE = 'dc=example,dc=com'
try:
conn = ldap.initialize(LDAP_SERVER)
except ldap.LDAPError, e:
sys.stderr.write("Fatal Error.n")
raise
# this may or may not raise an error, e.g. TLS error -8172
items = conn.search_s(LDAP_BASE, ldap.SCOPE_SUBTREE, attrlist=['dn'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment