LdapClient: fix get_object_by_dn() and get_object_by_dn() methods when populate cache method return no objects

This commit is contained in:
Benjamin Renard 2021-06-03 12:26:19 +02:00
parent 6e85515420
commit b9ba720798

View file

@ -424,6 +424,12 @@ class LdapClient:
if not populate_cache_method:
return False
populate_cache_method()
if type_name not in self._cached_objects:
if warn:
log.warning('No %s found in LDAP', type_name)
else:
log.debug('No %s found in LDAP', type_name)
return None
if dn not in self._cached_objects[type_name]:
if warn:
log.warning('No %s found with DN "%s"', type_name, dn)
@ -443,6 +449,12 @@ class LdapClient:
if not populate_cache_method:
return False
populate_cache_method()
if type_name not in self._cached_objects:
if warn:
log.warning('No %s found in LDAP', type_name)
else:
log.debug('No %s found in LDAP', type_name)
return None
matched = dict(
(dn, obj)
for dn, obj in self._cached_objects[type_name].items()