ldap: add DN to normalized results

This commit is contained in:
Serghei Mihai 2021-03-22 15:45:20 +01:00
parent 3e71128a9a
commit 1c3bac6c87
1 changed files with 4 additions and 7 deletions

View File

@ -1138,10 +1138,8 @@ class LDAPBackend(object):
for dn, attrs in results:
log.debug(u'Object retrieved for extra attr %s with item %s : %s %s' % (
extra_attribute_name, item, dn, attrs))
obj_attributes = attrs.copy()
obj_attributes['dn'] = dn
for key in ldap_attributes_mapping:
item_value[key] = obj_attributes.get(ldap_attributes_mapping[key].lower())
item_value[key] = attrs.get(ldap_attributes_mapping[key].lower())
log.debug('Object attribute %s value retrieved for extra attr %s with item %s : %s' % (
ldap_attributes_mapping[key], extra_attribute_name, item, item_value[key]))
if not item_value[key]:
@ -1341,9 +1339,8 @@ class LDAPBackend(object):
results = cls.paged_search(conn, user_basedn, ldap.SCOPE_SUBTREE, user_filter, attrlist=attribute_names)
backend = cls()
for dn, attrs in results:
data = attrs.copy()
data['dn'] = dn
yield backend._return_user(dn, None, conn, block, data)
yield backend._return_user(dn, None, conn, block, attrs)
@classmethod
def ad_encoding(cls, s):
@ -1381,7 +1378,7 @@ class LDAPBackend(object):
# ignore referrals
if not dn:
continue
new_attrs = {}
new_attrs = {'dn': dn}
for key in attrs:
try:
new_attrs[key.lower()] = [force_text(value, encoding) for value in attrs[key]]