Univention Bugzilla – Bug 49611
UCS@school roles are not correctly loaded in the lib
Last modified: 2023-06-23 13:15:26 CEST
If you get Computers with the school lib via SchoolComputer.get_all the roles are not correctly loaded the first time you use the function: In [1]: from univention.admin.uldap import getAdminConnection In [2]: from ucsschool.lib.models.computer import SchoolComputer In [3]: lo,po=getAdminConnection() In [4]: c1=SchoolComputer.get_all(lo, 'DEMOSCHOOL')[0] In [5]: c1 Out[5]: WindowsComputer(name='C1', school='DEMOSCHOOL', dn='cn=C1,cn=computers,ou=DEMOSCHOOL,dc=realm1,dc=intranet') In [6]: c1.ucsschool_roles Out[6]: [] In [7]: c1.modify(lo) --------------------------------------------------------------------------- ldapError Traceback (most recent call last) <ipython-input-7-37d852b82f23> in <module>() ----> 1 c1.modify(lo) /usr/lib/pymodules/python2.7/ucsschool/lib/models/base.pyc in modify(self, lo, validate, move_if_necessary) 531 ''' 532 self.call_hooks('pre', 'modify') --> 533 success = self.modify_without_hooks(lo, validate, move_if_necessary) 534 if success: 535 self.call_hooks('post', 'modify') /usr/lib/pymodules/python2.7/ucsschool/lib/models/computer.pyc in modify_without_hooks(self, lo, validate, move_if_necessary) 218 def modify_without_hooks(self, lo, validate=True, move_if_necessary=None): 219 self.create_network(lo) --> 220 return super(SchoolComputer, self).modify_without_hooks(lo, validate, move_if_necessary) 221 222 def get_ipv4_network(self): /usr/lib/pymodules/python2.7/ucsschool/lib/models/base.pyc in modify_without_hooks(self, lo, validate, move_if_necessary) 557 old_attrs = deepcopy(udm_obj.info) 558 self.modify_without_hooks_roles(udm_obj) --> 559 self.do_modify(udm_obj, lo) 560 # get it fresh from the database 561 self.set_dn(self.dn) /usr/lib/pymodules/python2.7/ucsschool/lib/models/base.pyc in do_modify(self, udm_obj, lo) 591 ''' 592 self._alter_udm_obj(udm_obj) --> 593 udm_obj.modify(ignore_license=1) 594 595 def move(self, lo, udm_obj=None, force=False): /usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.pyc in modify(self, modify_childs, ignore_license, serverctrls, response) 640 self.ready() 641 --> 642 dn = self._modify(modify_childs, ignore_license=ignore_license, response=response) 643 except: 644 self._save_cancel() /usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.pyc in _modify(self, modify_childs, ignore_license, response, serverctrls) 1310 # FIXME: timeout without exception if objectClass of Object is not exsistant !! 1311 univention.debug.debug(univention.debug.ADMIN, 99, 'Modify dn=%r;\nmodlist=%r;\noldattr=%r;' % (self.dn, ml, self.oldattr)) -> 1312 self.dn = self.lo.modify(self.dn, ml, ignore_license=ignore_license, serverctrls=serverctrls, response=response) 1313 if ml: 1314 self._write_admin_diary_modify() /usr/lib/pymodules/python2.7/univention/admin/uldap.pyc in modify(self, dn, changes, exceptions, ignore_license, serverctrls, response) 894 except ldap.LDAPError as msg: 895 univention.debug.debug(univention.debug.LDAP, univention.debug.ALL, 'mod dn=%s err=%s' % (dn, msg)) --> 896 raise univention.admin.uexceptions.ldapError(_err2str(msg), original_exception=msg) 897 898 def rename(self, dn, newdn, move_childs=0, ignore_license=False, serverctrls=None, response=None): ldapError: Type or value exists: modify/add: ucsschoolRole: value #0 already exists In [8]: c1.ucsschool_roles Out[8]: ['win_computer:school:DEMOSCHOOL'] In [9]: c1.modify(lo) Out[9]: True
The workaround for some reason is to call from_dn or get_all once before. After that the subsequent calls work as expected. This workaround has been used in Bug #48080 and should be removed once this bug is being fixed.
This issue has been filed against UCS 4.4. UCS 4.4 is out of maintenance and UCS components may have vastly changed in later releases. Thus, this issue is now being closed. If this issue still occurs in newer UCS versions, please use "Clone this bug" or reopen this issue. In this case please provide detailed information on how this issue is affecting you.