Fix NO_SUCH_OBJECT error when authenticating users using LDAP.
Review Request #14364 — Created March 8, 2025 and updated
When configuring Review Board to authenticate against an OpenLDAP server, the authentication process was failing with an
ldap.NO_SUCH_OBJECTerror.I found out that the error was raised inside the
LDAPBackend.get_or_create_usermethod, when retrieving the user info using theldapo.search_sbased on the DN. This happens after having successfully obtained the user info and authenticated it with the previoussearch_sandbind_scalls inLDAPBackend._get_user_dnandLDAPBackend.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_OBJECTerror. The problem was mitigated by setting theOPT_NETWORK_TIMEOUToption 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.authenticatemethod to theLDAPBackend.get_or_create_usermethod by means of an optional parameter. To achieve this, theLDAPBackend._get_user_dnmethod has been converted into theLDAPBackend._get_user_infomethod, 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.