Univention Bugzilla – Bug 41267
Simplify modlist generation
Last modified: 2022-06-24 13:57:22 CEST
We currently build a modlist manually in univention.admin.handlers.object._ldap_modlist(). The modlist may be altered by hooks. There is a lot of code which iterates through the modlist and modifies it or appends additional entries. This happens in _modify() as well as afterwards in univention.uldap.modify(). In univention.uldap.modify() we then reformat the modlist from a UDM-modlist into a python-ldap-modlist. This is generally much work, leads to hard-to-read-and-too-complex code and could be done much more simple! The better approach would be to generate a new dictionary with the new values. We then have self.oldattr and e.g. self.build_attributes(). The modlist could be generated automatically by python-ldap by diffing the both dictionaries. Here is a simple example: >>> from ldap.modlist import modifyModlist >>> oldattr = { ... 'objectClass':['person'], ... 'cn': ['SpaceOne'], ... 'sn': ['One'], ... 'test': ['a', 'b', 'C'], ... } >>> newattr = { ... 'objectClass':['Person'], ... 'cn': ['SpaceOne'], ... 'sn': [], ... 'test': ['a', 'b', 'c'], ... } >>> case_insensitive = ['objectClass'] >>> modifyModlist(oldattr, newattr, case_ignore_attr_types=case_insensitive) [(1, 'test', None), (0, 'test', ['a', 'b', 'c']), (1, 'sn', None)] The same would go for addlist. We could then also remove all the workarounds for boolean-syntaxes and jpegPhoto in univention.uldap.access.
For the addlist there is the function ldap.modlist.addModlist().
Bug #37556 would be fixed.
This issue has been filled against UCS 4.1. The maintenance with bug and security fixes for UCS 4.1 has ended on 5st of April 2018. Customers still on UCS 4.1 are encouraged to update to UCS 4.3. Please contact your partner or Univention for any questions. If this issue still occurs in newer UCS versions, please use "Clone this bug" or simply reopen the issue. In this case please provide detailed information on how this issue is affecting you.