Univention Bugzilla – Bug 42495
Membership of working groups or global groups get removed if user is modified via ucs-school-lib
Last modified: 2016-12-12 13:10:21 CET
Created attachment 8029 [details] patch Attached is the correct fix for Bug #41907. It reverts the things of Bug #41907 and Bug #42251. The test test_modify_with_several_groups() still pass with the patch. +++ This bug was initially created as a clone of Bug #41907 +++ If a user is modified via ucs-school-lib, the lib removes all group memberships that are not listed in school_classes. Even the memberships of - working groups - groups in school OU - global groups are removed.
The patch corrects the broken API and makes the workaround therefore obsolete. The patch should be applied in interim-3 round.
Applied the patch and did some whitespace pep8 E101 cleanup. ucs-school-lib (9.0.29-1): r74422 | Bug #42495: optimize internal handling of group modifications ucs-school-lib.yaml: r74423 | YAML Bug #42495
OK: automated tests: # for TEST in /usr/share/ucs-test/90_ucsschool/05_ucs-school-workinggroup-module-check /usr/share/ucs-test/90_ucsschool/36_import-groups_via_cli /usr/share/ucs-test/90_ucsschool/36_import-groups_via_python_api /usr/share/ucs-test/90_ucsschool/101_exam_mode_group_members /usr/share/ucs-test/90_ucsschool/105_activate_groupmembers /usr/share/ucs-test/90_ucsschool/213_import-users_modify_with_several_groups; do $TEST -f || break; done OK: advisory REOPEN: if a User is removed from a secondary school (not a school change), it's not removed from the classes and workgroups of that school: from ucsschool.lib.models import Student, WorkGroup stud3 = Student( school="SchuleEinz", schools=["SchuleEinz", "SchuleZwei"], name="stud3", email="stud3@uni.dtr", firstname="stud3fn", lastname="stud3ln", school_classes={"SchuleEinz": ["SchuleEinz-1A"], "SchuleZwei": ["SchuleZwei-2B"]}) stud3.create(lo) WorkGroup(school="SchuleEinz", name="wg1", users=[stud3.dn]).create(lo) WorkGroup(school="SchuleZwei", name="wg2", users=[stud3.dn]).create(lo) stud3 = Student.from_dn(stud3.dn, None, lo) print 'stud3.school:', stud3.school print 'stud3.schools:', stud3.schools print 'stud3.school_classes:', stud3.school_classes print 'stud3.get_udm_object(lo)[groups]:', stud3.get_udm_object(lo)['groups'] =============================================================== stud3.school: SchuleEinz stud3.schools: ['SchuleZwei', 'SchuleEinz'] stud3.school_classes: {'SchuleZwei': ['SchuleZwei-2B'], 'SchuleEinz': ['SchuleEinz-1A']} stud3.get_udm_object(lo)[groups]: ['cn=schueler-schuleeinz,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=Domain Users schuleeinz,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=SchuleEinz-1A,cn=klassen,cn=schueler,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=schueler-schulezwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr', 'cn=Domain Users SchuleZwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr', 'cn=SchuleZwei-2B,cn=klassen,cn=schueler,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr', 'cn=wg1,cn=schueler,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=wg2,cn=schueler,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr'] =============================================================== stud3.schools.remove('SchuleZwei') stud3.modify(lo) print 'stud3.school:', stud3.school print 'stud3.schools:', stud3.schools print 'stud3.school_classes:', stud3.school_classes print 'stud3.get_udm_object(lo)[groups]:', stud3.get_udm_object(lo)['groups'] =============================================================== stud3.school: SchuleEinz stud3.schools: ['SchuleEinz'] stud3.school_classes: {'SchuleZwei': ['SchuleZwei-2B'], 'SchuleEinz': ['SchuleEinz-1A']} stud3.get_udm_object(lo)[groups]: ['cn=schueler-schuleeinz,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=Domain Users schuleeinz,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=SchuleEinz-1A,cn=klassen,cn=schueler,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=schueler-schulezwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr', 'cn=Domain Users SchuleZwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr', 'cn=SchuleZwei-2B,cn=klassen,cn=schueler,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr', 'cn=wg1,cn=schueler,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=wg2,cn=schueler,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr'] Removing 'SchuleZwei' from school_classes (stud3.school_classes.pop('SchuleZwei')) doesn't change this. When fixing, please enhance 213_import-users_modify_with_several_groups to check for this case.
(In reply to Daniel Tröder from comment #3) > REOPEN: if a User is removed from a secondary school (not a school change), > it's not removed from the classes and workgroups of that school: > stud3.schools.remove('SchuleZwei') → Please use the official way to remove the user from that school: stud3.remove_from_school('SchuleZwei', lo) If you want the API be changed for supporting schools.remove() then please fill a new bug.
(In reply to Florian Best from comment #4) > (In reply to Daniel Tröder from comment #3) > > REOPEN: if a User is removed from a secondary school (not a school change), > > it's not removed from the classes and workgroups of that school: > > > stud3.schools.remove('SchuleZwei') > → Please use the official way to remove the user from that school: > stud3.remove_from_school('SchuleZwei', lo) OK - that works as expected. With this, all is verified. > If you want the API be changed for supporting schools.remove() then please > fill a new bug. I don't want the API changed - I want it documented.
UCS@school 4.1 R2 v9 has been released. http://docs.software-univention.de/changelog-ucsschool-4.1R2v9-de.html