Univention Bugzilla – Bug 54131
NotSupportedError during user deletion if "username" instead of "name" is used in the mapping
Last modified: 2021-11-24 15:26:17 CET
NotSupportedError during user deletion if "username" instead of "name" is used in the mapping username and mailPrimaryAddress are detected as udm_properties. For user creation and modification these are removed from udm_properties in their respective make_username, make_email function. The make_* functions are not called during user deletion. The user is read as is from ldap. Since username (and/or mailPrimaryAddress) was never removed from udm_properties in case the user should be deleted, a error will be thrown [1]. username and mailPrimaryAddress need to be removed from udm_properties, for users that should be deleted, as well. This is a regression from bug 53649, which add udm_prperties to users which should be deleted. [1] Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/ucsschool/importer/mass_import/user_import.py", line 491, in delete_users success = self.do_delete(user) File "/usr/lib/python2.7/dist-packages/ucsschool/importer/mass_import/user_import.py", line 625, in do_delete success = user.modify(lo=self.connection, validate=False) File "/usr/lib/python2.7/dist-packages/ucsschool/importer/models/import_user.py", line 1057, in modify res = super(ImportUser, self).modify(lo, validate, move_if_necessary) File "/usr/lib/python2.7/dist-packages/ucsschool/lib/models/base.py", line 674, in modify success = self.modify_without_hooks(lo, validate, move_if_necessary) File "/usr/lib/python2.7/dist-packages/ucsschool/importer/models/import_user.py", line 1093, in modify_without_hooks return super(ImportUser, self).modify_without_hooks(lo, validate, move_if_necessary) File "/usr/lib/python2.7/dist-packages/ucsschool/lib/models/base.py", line 701, in modify_without_hooks self.do_modify(udm_obj, lo) File "/usr/lib/python2.7/dist-packages/ucsschool/lib/models/user.py", line 330, in do_modify return super(User, self).do_modify(udm_obj, lo) File "/usr/lib/python2.7/dist-packages/ucsschool/lib/models/base.py", line 735, in do_modify self._alter_udm_obj(udm_obj) File "/usr/lib/python2.7/dist-packages/ucsschool/importer/models/import_user.py", line 501, in _alter_udm_obj self._prevent_mapped_attributes_in_udm_properties() File "/usr/lib/python2.7/dist-packages/ucsschool/importer/models/import_user.py", line 1591, in _prevent_mapped_attributes_in_udm_properties "udm_properties).".format("', '".join(bad_props), self.__class__.__name__) NotSupportedError: UDM properties 'username' must be set as attributes of the ImportStudent object (not in udm_properties).
Workaround: use "name" instead of "username" in the mapping. use "email" instead of "mailPrimaryAddress" in the mapping.
IMHO this is a user error, not a software error. That is why a NotSupportedError is raised with an explanation, how the user can fix it. _prevent_mapped_attributes_in_udm_properties() is only called when a create() or modify() operation is done. In the delete() case a modify() happens, when a user get actually _deactivated_, instead of immediately deleted. But nevertheless we want to stop the import as early as possible in the case of errors. So the check for udm_properties that should be ucsschool.lib user attributes should be done in a ConfigurationCheck. This will not prevent problems created by hooks, but the case in this bug could have been prevented. So I suggest to add a "test_mapped_attributes_not_in_udm_properties()" to ucs-school-import/usr/share/ucs-school-import/checks/defaults.py that does basically the same as "ImportUser._prevent_mapped_attributes_in_udm_properties()".