ldap.LdapClient: fix errors handling changes on RDN attribute

This commit is contained in:
Benjamin Renard 2021-12-08 18:19:10 +01:00
parent 947ed765aa
commit 26e7b8efd1

View file

@ -722,9 +722,9 @@ class LdapClient:
) )
# Compute new object DN # Compute new object DN
dn_parts = ldap_obj['dn'].split(',') dn_parts = self.decode(ldap_obj['dn']).split(',')
basedn = ','.join(dn_parts[1:]) basedn = ','.join(dn_parts[1:])
new_rdn = '%s=%s' % (rdn_attr, new_rdn_values[0]) new_rdn = '%s=%s' % (rdn_attr, self.decode(new_rdn_values[0]))
new_dn = '%s,%s' % (new_rdn, basedn) new_dn = '%s,%s' % (new_rdn, basedn)
# Rename object # Rename object
@ -733,10 +733,10 @@ class LdapClient:
return False return False
# Remove RDN in changes list # Remove RDN in changes list
for attr in changes[0].keys(): for attr in list(changes[0].keys()):
if attr.lower() == rdn_attr.lower(): if attr.lower() == rdn_attr.lower():
del changes[0][attr] del changes[0][attr]
for attr in changes[1].keys(): for attr in list(changes[1].keys()):
if attr.lower() == rdn_attr.lower(): if attr.lower() == rdn_attr.lower():
del changes[1][attr] del changes[1][attr]