1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-22 09:24:21 +01:00

implementing renaming entry

This commit is contained in:
kakwa 2015-07-28 00:18:05 +02:00
parent ac0a3473f7
commit e3fe0b4bfb

View File

@ -289,16 +289,23 @@ class Backend(ldapcherry.backend.Backend):
content = self._str(attrs[attr]) content = self._str(attrs[attr])
attr = self._str(attr) attr = self._str(attr)
new = {attr: content} new = {attr: content}
if attr in old_attrs: # if attr is dn entry, use rename
old = {attr: old_attrs[attr]} if attr.lower() == self.dn_user_attr.lower():
ldap_client.rename_s(
dn,
ldap.dn.dn2str([[(attr, content, 1)]])
)
else: else:
old = {} if attr in old_attrs:
ldif = modlist.modifyModlist(old, new) old = {attr: old_attrs[attr]}
try: else:
ldap_client.modify_s(dn, ldif) old = {}
except Exception as e: ldif = modlist.modifyModlist(old, new)
ldap_client.unbind_s() try:
self._exception_handler(e) ldap_client.modify_s(dn, ldif)
except Exception as e:
ldap_client.unbind_s()
self._exception_handler(e)
ldap_client.unbind_s() ldap_client.unbind_s()