0

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'])
GeoCom
  • 1,290
  • 2
  • 12
  • 33

1 Answers1

1

Explain it to someone, in this case here, then it will pop up some possible fix into your head

so the issue was I had to attach the VPC with correct Security group into Lmbda configuration.

GeoCom
  • 1,290
  • 2
  • 12
  • 33
  • 1
    In short, you needed to [configure the Lambda function to access resources in your VPC](https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html), by the sound of things. – jarmod Sep 12 '22 at 19:04