Fix NO_SUCH_OBJECT error when authenticating users using LDAP.

Review Request #14364 — Created March 8, 2025 and updated

Information

Review Board

Reviewers

When configuring Review Board to authenticate against an OpenLDAP server, the authentication process was failing with an ldap.NO_SUCH_OBJECT error.

I found out that the error was raised inside the LDAPBackend.get_or_create_user method, when retrieving the user info using the ldapo.search_s based on the DN. This happens after having successfully obtained the user info and authenticated it with the previous search_s and bind_s calls in LDAPBackend._get_user_dn and LDAPBackend.authenticate.

Investigating a bit with delays between consecutive LDAP searches I reproduced the problem, it seems as if there was some king of timeout with the LDAP connection that is incorrectly reported as an NO_SUCH_OBJECT error. The problem was mitigated by setting the OPT_NETWORK_TIMEOUT option to a reasonable value (5 seconds).

Anyway, since the problem was caused by the fact that the user info was redudantly requested a second time (this information was already available from the first LDAP search), I also optimized the code to pass the retrieved user information from the LDAPBackend.authenticate method to the LDAPBackend.get_or_create_user method by means of an optional parameter. To achieve this, the LDAPBackend._get_user_dn method has been converted into the LDAPBackend._get_user_info method, which instead of returning just the DN it returns all the user info as obtained by the LDAP search.

Authentication of several users using LDAP on our Review Board instance running on our on-premises Ubuntu 24.04 LTS server.

Checks run (2 succeeded)
flake8 passed.
JSHint passed.
Loading...