## Scenario: * ucsschool=5.0 v3 * UCS: 5.0-2 errata393 * SiSoPi * Import-Hook ext_config_dep_on_role enabled * ucsschool/wizards/schoolwizards/users/roles/disabled: staff,teachersAndStaff → school_admins are enabled ## Logs: 2022-09-07 11:16:56 DEBUG import_user.ImportUser:136 Used no-overwrite-attributes: ['mailPrimaryAddress', 'uid'] 2022-09-07 11:16:57 INFO ucs-school-purge-expired-users.main:161 Found 17 expired accounts. ... 2022-09-07 11:16:57 DEBUG ucs-school-purge-expired-users.main:171 dn='uid=dienstag,cn=schueler,cn=users,ou=DeaktivierteKonten,dc=qs,dc=schule-sh,dc=de' ucsschoolPurgeTimestamp='2022-05-03' shadowExpire='1970-01-02' 2022-09-07 11:16:57 INFO ucs-school-purge-expired-users.main:176 (dry-run) Deleting 'uid=admin2,cn=admins,cn=users,ou=DeaktivierteKonten,dc=qs,dc=schule-sh,dc=de'... Traceback (most recent call last): File "/usr/share/ucs-school-import/scripts/ucs-school-purge-expired-users", line 195, in <module> sys.exit(main()) File "/usr/share/ucs-school-import/scripts/ucs-school-purge-expired-users", line 185, in main roles = roles_from_ocs([x.decode("UTF-8") for x in attr["objectClass"]], a_user, school) File "/usr/share/ucs-school-import/scripts/ucs-school-purge-expired-users", line 103, in roles_from_ocs return kls.roles AttributeError: 'NoneType' object has no attribute 'roles' → the 1st user is a school admin, but passes the UCS@School consistency check. ## Code ### ucs-school-import/usr/share/ucs-school-import/scripts/ucs-school-purge-expired-users:L95-103 The function roles_from_ocs() calls get_class_for_udm_obj() on an ImportUser object, but gets None back. ### ucs-school-import/modules/ucsschool/importer/models/import_user.py:L1576-1591 The function get_class_for_udm_obj() misses the user role "school_admin" and therefore returns 'None'!
Created attachment 10986 [details] MWE for a working script without using the ImportUser factory
I found a (hacky?) way of doing this with the ucsschool-lib User object instead, which works with School Admins, too.
After discussing this and thinking it through we should ignore sole school admin accounts when purging users, because these accounts cannot be created via an import and the purge routine is part of the importer-based lifecycle.
Package: ucs-test-ucsschool Version: 7.3.185 Branch: 5.0-0 Scope: ucs-school-5.0 Package: ucs-school-import Version: 18.0.46 Branch: 5.0-0 Scope: ucs-school-5.0
Package update with resolution published on 02.07.2024 for UCS@school 5.0v5. See https://docs.software-univention.de/ucsschool-changelog/5.0v5/en/index.html