Bug 41640 - User.create() doesn't create classes of additional schools
User.create() doesn't create classes of additional schools
Status: CLOSED INVALID
Product: UCS@school
Classification: Unclassified
Component: Ucsschool-lib
UCS@school 4.1 R2
Other Linux
: P5 normal (vote)
: UCS@school 4.1 R2 vXXX
Assigned To: Bugzilla Mailingliste
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-06-22 17:36 CEST by Daniel Tröder
Modified: 2023-03-25 06:50 CET (History)
1 user (show)

See Also:
What kind of report is it?: ---
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):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2016-06-22 17:36:46 CEST
teacher1 = Teacher(name="ateacher", firstname="fn", lastname="ln", school="schule1", school_classes={"schule1": ["schule1-kl1", "schule1-kl2"], "schule2": ["schule2-kl3", "schule2-kl4"]})

teacher1.school_classes
→ {'schule1': ['schule1-kl1', 'schule1-kl2'], 'schule2': ['schule2-kl3', 'schule2-kl4']}

teacher1.create(lo)
→
/usr/share/ucs-school-import/hooks/user_create_pre.d shall be executed
Building hook line: Teacher(name='ateacher', school='schule1', dn='uid=ateacher,cn=lehrer,cn=users,ou=schule1,dc=uni,dc=dtr').build_hook_line('pre', 'create')
Getting Teacher UDM object by filter: username=ateacher
Creating Teacher(name='ateacher', school='schule1', dn='uid=ateacher,cn=lehrer,cn=users,ou=schule1,dc=uni,dc=dtr')
No password given. Generating random one
Initializing ('SchoolClass', ('name', 'schule1-kl1'), ('school', 'schule1'))
Initializing ('SchoolClass', ('name', 'schule1-kl2'), ('school', 'schule1'))
Initializing ('SchoolClass', ('name', 'schule2-kl3'), ('school', 'schule2'))
Initializing ('SchoolClass', ('name', 'schule2-kl4'), ('school', 'schule2'))
Getting SchoolClass UDM object by filter: name=schule1-kl1
Creating SchoolClass(name='schule1-kl1', school='schule1', dn='cn=schule1-kl1,cn=klassen,cn=schueler,cn=groups,ou=schule1,dc=uni,dc=dtr')
SchoolClass(name='schule1-kl1', school='schule1', dn='cn=schule1-kl1,cn=klassen,cn=schueler,cn=groups,ou=schule1,dc=uni,dc=dtr') successfully created
Invalidating ('SchoolClass', ('name', 'schule1-kl2'), ('school', 'schule1'))
Invalidating ('SchoolClass', ('name', 'schule1-kl1'), ('school', 'schule1'))
Invalidating ('SchoolClass', ('name', 'schule2-kl4'), ('school', 'schule2'))
Invalidating ('SchoolClass', ('name', 'schule2-kl3'), ('school', 'schule2'))
Getting SchoolClass UDM object by filter: name=schule1-kl1
Getting ClassShare UDM object by dn: cn=schule1-kl1,cn=klassen,cn=shares,ou=schule1,dc=uni,dc=dtr
Creating ClassShare(name='schule1-kl1', school='schule1', dn='cn=schule1-kl1,cn=klassen,cn=shares,ou=schule1,dc=uni,dc=dtr')
Looking up School with dn 'ou=schule1,dc=uni,dc=dtr'
Creating share on "sl-schule1.uni.dtr"
ClassShare(name='schule1-kl1', school='schule1', dn='cn=schule1-kl1,cn=klassen,cn=shares,ou=schule1,dc=uni,dc=dtr') successfully created
Initializing ('SchoolClass', ('name', 'schule1-kl2'), ('school', 'schule1'))
Getting SchoolClass UDM object by filter: name=schule1-kl2
Creating SchoolClass(name='schule1-kl2', school='schule1', dn='cn=schule1-kl2,cn=klassen,cn=schueler,cn=groups,ou=schule1,dc=uni,dc=dtr')
SchoolClass(name='schule1-kl2', school='schule1', dn='cn=schule1-kl2,cn=klassen,cn=schueler,cn=groups,ou=schule1,dc=uni,dc=dtr') successfully created
Invalidating ('SchoolClass', ('name', 'schule1-kl2'), ('school', 'schule1'))
Getting SchoolClass UDM object by filter: name=schule1-kl2
Getting ClassShare UDM object by dn: cn=schule1-kl2,cn=klassen,cn=shares,ou=schule1,dc=uni,dc=dtr
Creating ClassShare(name='schule1-kl2', school='schule1', dn='cn=schule1-kl2,cn=klassen,cn=shares,ou=schule1,dc=uni,dc=dtr')
Looking up School with dn 'ou=schule1,dc=uni,dc=dtr'
Creating share on "sl-schule1.uni.dtr"
ClassShare(name='schule1-kl2', school='schule1', dn='cn=schule1-kl2,cn=klassen,cn=shares,ou=schule1,dc=uni,dc=dtr') successfully created
Initializing ('Group', ('name', 'schule2-kl3'), ('school', 'schule1'))
Getting Group UDM object by filter: name=schule2-kl3
Creating Group(name='schule2-kl3', school='schule1', dn='cn=schule2-kl3,cn=groups,ou=schule1,dc=uni,dc=dtr')
Group(name='schule2-kl3', school='schule1', dn='cn=schule2-kl3,cn=groups,ou=schule1,dc=uni,dc=dtr') successfully created
Invalidating ('Group', ('name', 'schule2-kl3'), ('school', 'schule1'))
Invalidating ('Group', ('name', 'Domain Users schule1'), ('school', 'schule1'))
Invalidating ('Group', ('name', 'lehrer-schule1'), ('school', 'schule1'))
Initializing ('Group', ('name', 'schule2-kl4'), ('school', 'schule1'))
Getting Group UDM object by filter: name=schule2-kl4
Creating Group(name='schule2-kl4', school='schule1', dn='cn=schule2-kl4,cn=groups,ou=schule1,dc=uni,dc=dtr')
Group(name='schule2-kl4', school='schule1', dn='cn=schule2-kl4,cn=groups,ou=schule1,dc=uni,dc=dtr') successfully created
Invalidating ('Group', ('name', 'schule2-kl4'), ('school', 'schule1'))
Initializing ('Group', ('name', 'lehrer-schule1'), ('school', 'schule1'))
Getting Group UDM object by filter: name=lehrer-schule1

---------------------------------------------------------------------------
noObject                                  Traceback (most recent call last)
<ipython-input-20-c1e6f2a3e818> in <module>()
----> 1 teacher1.create(lo)

/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.pyc in create(self, lo, validate)
    415 		'''
    416                 self.call_hooks('pre', 'create')
--> 417                 success = self.create_without_hooks(lo, validate)
    418                 if success:
    419                         self.call_hooks('post', 'create')

/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.pyc in create_without_hooks(self, lo, validate)
    441 
    442                         # here is the real logic
--> 443                         self.do_create(udm_obj, lo)
    444 
    445                         # get it fresh from the database (needed for udm_obj._exists ...)

/usr/lib/pymodules/python2.7/ucsschool/lib/models/user.pyc in do_create(self, udm_obj, lo)
    245                 if script_path is not None:
    246                         udm_obj['scriptpath'] = script_path
--> 247                 success = super(User, self).do_create(udm_obj, lo)
    248                 if password_created:
    249                         # to not show up in host_hooks

/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.pyc in do_create(self, udm_obj, lo)
    458 		'''
    459                 self._alter_udm_obj(udm_obj)
--> 460                 udm_obj.create()
    461 
    462         def modify(self, lo, validate=True, move_if_necessary=None):

/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.pyc in create(self)
    293                         raise univention.admin.uexceptions.insufficientInformation
    294 
--> 295                 return self._create()
    296 
    297         def modify(self, modify_childs=1,ignore_license=0):

/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.pyc in _create(self)
    710                 # if anything goes wrong we need to remove the already created object, otherwise we run into 'already exists' errors
    711                 try:
--> 712                         self._ldap_post_create()
    713                 except:
    714                         # ensure that there is no lock left

/usr/lib/pymodules/python2.7/univention/admin/handlers/users/user.pyc in _ldap_post_create(self)
   1867                 if 'posix' in self.options:
   1868                         univention.admin.allocators.confirm(self.lo, self.position, 'uidNumber', self.uidNum)
-> 1869                         self.__update_groups()
   1870                         self.__primary_group()
   1871 

/usr/lib/pymodules/python2.7/univention/admin/handlers/users/user.pyc in __update_groups(self)
   1664                         if group and not case_insensitive_in_list(group, old_groups):
   1665                                 grpobj = group_mod.object(None, self.lo, self.position, group)
-> 1666                                 grpobj.fast_member_add( [ self.dn ], [ new_uid ] )
   1667 
   1668                 if univention.admin.baseConfig.is_true("directory/manager/user/primarygroup/update", True):

/usr/lib/pymodules/python2.7/univention/admin/handlers/groups/group.pyc in fast_member_add(self, memberdnlist, uidlist)
    430                 if ml:
    431                         try:
--> 432                                 return self.lo.modify(self.dn, ml)
    433                         except ldap.NO_SUCH_OBJECT, msg:
    434                                 raise univention.admin.uexceptions.noObject

/usr/lib/pymodules/python2.7/univention/admin/uldap.pyc in modify(self, dn, changes, exceptions, ignore_license)
    419                 except ldap.NO_SUCH_OBJECT, msg:
    420                         univention.debug.debug(univention.debug.LDAP, univention.debug.ALL, 'mod dn=%s err=%s' % (dn, msg))
--> 421                         raise univention.admin.uexceptions.noObject(dn)
    422                 except ldap.INSUFFICIENT_ACCESS, msg:
    423                         univention.debug.debug(univention.debug.LDAP, univention.debug.ALL, 'mod dn=%s err=%s' % (dn, msg))

noObject: cn=schule2-kl3,cn=klassen,cn=schueler,cn=groups,ou=schule2,dc=uni,dc=dtr



When grepping in log for "Creating", it can be seen, that the classes of the second school are only created as Group and not below cn=klassen,cn=schueler:

Creating Teacher(name='ateacher', school='schule1', dn='uid=ateacher,cn=lehrer,cn=users,ou=schule1,dc=uni,dc=dtr')
Creating SchoolClass(name='schule1-kl1', school='schule1', dn='cn=schule1-kl1,cn=klassen,cn=schueler,cn=groups,ou=schule1,dc=uni,dc=dtr')
Creating ClassShare(name='schule1-kl1', school='schule1', dn='cn=schule1-kl1,cn=klassen,cn=shares,ou=schule1,dc=uni,dc=dtr')
Creating share on "sl-schule1.uni.dtr"
Creating SchoolClass(name='schule1-kl2', school='schule1', dn='cn=schule1-kl2,cn=klassen,cn=schueler,cn=groups,ou=schule1,dc=uni,dc=dtr')
Creating ClassShare(name='schule1-kl2', school='schule1', dn='cn=schule1-kl2,cn=klassen,cn=shares,ou=schule1,dc=uni,dc=dtr')
Creating share on "sl-schule1.uni.dtr"
Creating Group(name='schule2-kl3', school='schule1', dn='cn=schule2-kl3,cn=groups,ou=schule1,dc=uni,dc=dtr')
Creating Group(name='schule2-kl4', school='schule1', dn='cn=schule2-kl4,cn=groups,ou=schule1,dc=uni,dc=dtr')
Comment 1 Florian Best univentionstaff 2016-06-23 10:17:47 CEST
Should be fixed by Bug #41601?

*** This bug has been marked as a duplicate of bug 41601 ***
Comment 2 Florian Best univentionstaff 2016-06-23 10:24:23 CEST
Ah no, you didn't specify the schools:

teacher1.schools = ['schule1', 'schule2']
teacher1.create(lo)

→ will work!
Comment 3 Daniel Tröder univentionstaff 2016-07-01 13:16:05 CEST
(In reply to Florian Best from comment #2)
> Ah no, you didn't specify the schools:
> 
> teacher1.schools = ['schule1', 'schule2']
> teacher1.create(lo)
> 
> → will work!
Correct