Skip to content

LDAP Giving 500 Error #68224

Description

@litesh1998

Under which category would you file this issue?

Providers

Apache Airflow version

3.2.2

What happened and how to reproduce it?

When configuring LDAP authentication in Airflow 3, login attempts failed with an exception indicating that the ldap.filter module could not be found. The LDAP provider code imports and uses ldap.filter.escape_filter_chars(), but the ldap.filter submodule is not automatically imported by the python-ldap package in some environments.

As a result, LDAP authentication fails even though the python-ldap package is installed and functional.

Additionally, it was working on 3.6.2 but not working for 3.6.5

How to reproduce it?

  1. Install Airflow 3 with LDAP authentication enabled.
  2. Install python-ldap (e.g. version 3.4.7).
  3. Configure LDAP authentication according to the Airflow documentation.
  4. Start the Airflow webserver.
  5. Attempt to log in using an LDAP user.
  6. Observe that authentication fails with:
    AttributeError: module 'ldap' has no attribute 'filter'

The issue is resolved by explicitly importing ldap.filter before LDAP authentication code is executed. This suggests the provider should explicitly import ldap.filter rather than assuming it is available as an attribute of the ldap module.

What you think should happen instead?

LDAP authentication should work successfully when the supported python-ldap package is installed and configured correctly.

The LDAP provider should explicitly import any required submodules (such as ldap.filter) instead of assuming they are automatically available as attributes of the top-level ldap package.

If a required dependency is missing, Airflow should fail gracefully with a clear error message indicating the missing module, rather than raising:

AttributeError: module 'ldap' has no attribute 'filter'

Users should be able to configure and use LDAP authentication following the documented setup steps without needing to manually modify provider code or add additional imports.

Operating System

Rocky linux

Deployment

Virtualenv installation

Apache Airflow Provider(s)

fab

Versions of Apache Airflow Providers

3.6.5

Official Helm Chart version

Not Applicable

Kubernetes Version

No response

Helm Chart configuration

No response

Docker Image customizations

No response

Anything else?

webserver.py (redacted)

from airflow.providers.fab.auth_manager.auth_manager import FabAuthManager

AUTH_TYPE = AUTH_LDAP

AUTH_LDAP_SERVER = "ldaps://ldap.example.com"
AUTH_LDAP_SEARCH = "OU=Users,DC=example,DC=com"
AUTH_LDAP_BIND_USER = "svc.airflow"
AUTH_LDAP_BIND_PASSWORD = "REDACTED"

SECURITY_MANAGER_CLASS = "CustomSecurityManager"

Login fails with:

AttributeError: module 'ldap' has no attribute 'filter'

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions