Bug 41267 - Simplify modlist generation
Simplify modlist generation
Status: REOPENED
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 4.4
Other Linux
: P5 normal with 2 votes (vote)
: ---
Assigned To: UMC maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-05-12 10:29 CEST by Florian Best
Modified: 2022-06-24 13:57 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Cleanup, Debt Technical
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2016-05-12 10:29:29 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.
Comment 1 Florian Best univentionstaff 2016-05-12 10:53:33 CEST
For the addlist there is the function ldap.modlist.addModlist().
Comment 2 Florian Best univentionstaff 2016-05-25 15:39:32 CEST
Bug #37556 would be fixed.
Comment 3 Stefan Gohmann univentionstaff 2019-01-03 07:19:23 CET
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.