ldap: prevent crash when recording a timeout failure (#73342) #9

Merged
bdauvergne merged 1 commits from wip/73342-ldap-erreur-log-erreur-TypeError into main 2023-03-24 15:37:42 +01:00
1 changed files with 2 additions and 2 deletions

View File

@ -1563,11 +1563,11 @@ class LDAPBackend:
attributes = attributes or self.get_ldap_attributes(block, conn, user_id)
ou = self._get_target_ou(block)
for lookup_type in block['lookups']:
if lookup_type == 'external_id':
if lookup_type == 'external_id' and attributes:
user = self._lookup_by_external_id(block=block, attributes=attributes)
elif lookup_type == 'username':
user = self._lookup_by_username(ou=ou, block=block, username=user_id)
elif lookup_type == 'email':
elif lookup_type == 'email' and attributes:
user = self._lookup_by_email(ou=ou, block=block, attributes=attributes)
if user:
break