Skip to content

Intermittent errors from LDAP cause django-auth-ldap to return partial groups list #378

@intgr

Description

@intgr

When there's an LDAP error in the middle of an LDAP connection, such as intermittent network errors, django-auth-ldap will return a partial list of LDAP groups.

This is because NestedMemberDNGroupType calls LDAPSearch.execute() in a loop. The latter method ignores all errors without propagating them, and just substituting any failure with an empty result set.

class LDAPSearch:
    # ...
    def execute(self, connection, filterargs=(), escape=True):
        # ...
        try:
            # ...
            results = connection.search_s(
                self.base_dn, self.scope, filterstr, self.attrlist
            )
        except ldap.LDAPError as e:
            results = []                           # <---
            logger.error(...)

        return self._process_results(results)

Returning partial results is a much worse behavior than propagating the error. It won't be clear to other code nor the user that an issue occurred, and they will have really inconsistent experience in the application, with some actions arbitrarily forbidden.

It also prevents implementing any retry logic in my application.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy