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_OBJECT
error.I found out that the error was raised inside the
LDAPBackend.get_or_create_user
method, when retrieving the user info using theldapo.search_s
based on the DN. This happens after having successfully obtained the user info and authenticated it with the previoussearch_s
andbind_s
calls inLDAPBackend._get_user_dn
andLDAPBackend.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 theOPT_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 theLDAPBackend.get_or_create_user
method by means of an optional parameter. To achieve this, theLDAPBackend._get_user_dn
method has been converted into theLDAPBackend._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.