Created
February 2, 2023 12:29
-
-
Save amalgjose/71009d46e01d6111db0dfd58383cd010 to your computer and use it in GitHub Desktop.
test code
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 | |
ldap_host = "" | |
pem_file_loc = "" | |
ldap_bind_dn = "" | |
conn = ldap.initialize(ldap_host) | |
conn.protocol_version = ldap.VERSION3 | |
conn.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_DEMAND) | |
conn.set_option(ldap.OPT_X_TLS_CACERTFILE, pem_file_loc) | |
conn.set_option(ldap.OPT_X_TLS_NEWCTX, 0) | |
conn.simple_bind_s(ldap_bind_dn, 'ldap_password') | |
result = conn.search_s('dc=somedomain,dc=com', | |
ldap.SCOPE_SUBTREE, | |
'[email protected]', | |
['memberOf']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment