Last active
July 29, 2018 11:08
-
-
Save morteza-mori/1408bddc3aa05fd38312ea14e4a85dcb to your computer and use it in GitHub Desktop.
ldap test python
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, sys | |
LDAP_SERVER = 'ldaps://grep01.test.test.ir' | |
LDAP_BASE = 'ou=Special Users,dc=gandou,dc=test,dc=test,dc=ir' | |
BIND_USER = 'uid=ibsngproxy,ou=Users,dc=test,dc=test,dc=ir' | |
BIND_PASSWORD = 'halohalohalo' | |
ldap.set_option(ldap.OPT_DEBUG_LEVEL, 4095) | |
try: | |
l = ldap.initialize(LDAP_SERVER) | |
except ldap.LDAPError, e: | |
sys.stderr.write("Fatal Error\n") | |
raise | |
try: | |
l.protocol_version = ldap.VERSION3 | |
l.simple_bind_s(BIND_USER, BIND_PASSWORD) | |
result = l.search_s(LDAP_BASE, ldap.SCOPE_SUBTREE) | |
print result | |
print "OK" | |
l.unbind() | |
except Exception, error: | |
print error | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment