Created
May 13, 2015 17:25
-
-
Save dnozay/9accf51947968e30fab5 to your computer and use it in GitHub Desktop.
python-ldap simple test script
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
#!/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