try to find user information from ldap, but I get the timed out
error. locally it is working
I've tried with both python-ldap
and ldap3
at this moment, I am confused as I see some documentation and instruction how to use/deploy ldap on AWS Lambda but also found from AWS doc Lambda supports two types of connections: TCP (Transmission Control Protocol) and UDP (User Datagram Protocol).
so at the end, is it possible to connect to ldap?
import ldap
def lambda_handler(event, context):
baseDN = 'xxx'
searchDN = 'xxx'
pw = "xxx"
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
ldap_host = 'ldaps://ldap-server:3377'
ldap_conn = ldap.initialize(ldap_host)
ldap_conn.simple_bind_s(baseDN, pw)
user = 'testuser'
result = ldap_conn.search_s(searchDN,
ldap.SCOPE_SUBTREE,
f'(sAMAccountName={user})',['userAccountControl'])