Bug 55179 - ucs-school-purge-expired-users can't handle school_admins
ucs-school-purge-expired-users can't handle school_admins
Status: NEW
Product: UCS@school
Classification: Unclassified
Component: Import scripts
UCS@school 5.0
Other Linux
: P5 normal (vote)
: ---
Assigned To: UCS@school maintainers
https://univention.plan.io/issues/34653
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2022-09-07 11:35 CEST by Oliver Friedrich
Modified: 2023-11-20 08:34 CET (History)
2 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 4: Minor Usability: Impairs usability in secondary scenarios
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 3: A User would likely not purchase the product
User Pain: 0.137
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments
MWE for a working script without using the ImportUser factory (5.54 KB, text/x-python)
2022-09-07 16:33 CEST, Oliver Friedrich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Friedrich univentionstaff 2022-09-07 11:35:38 CEST
## 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'!
Comment 1 Oliver Friedrich univentionstaff 2022-09-07 16:33:18 CEST
Created attachment 10986 [details]
MWE for a working script without using the ImportUser factory
Comment 2 Oliver Friedrich univentionstaff 2022-09-07 16:34:23 CEST
I found a (hacky?) way of doing this with the ucsschool-lib User object instead, which works with School Admins, too.