Problem: You get a traceback if you open classes

Problem:

You get a traceback if you open classes in the umc

Interner Server-Fehler in "schoolusers/query (student)".
Request: schoolusers/query (student)
 
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/univention/management/console/base.py", line 260, in execute
    function.__func__(self, request, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 181, in _response
    return function(self, request)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/schoolldap.py", line 145, in wrapper_func
    return func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/schoolusers/__init__.py", line 90, in query
    attr=['givenName', 'sn', 'shadowLastChange', 'shadowMax', 'uid'])
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/schoolldap.py", line 531, in _users_ldap
    ldap_objs = ldap_connection.search(search_filter, base=userdn, attr=attr)
  File "/usr/lib/pymodules/python2.7/univention/admin/uldap.py", line 755, in search
    raise univention.admin.uexceptions.noObject(_err2str(msg))
noObject: No such object

Investigation:

The traceback shows, that a user is in two classes but he is not on both schools.

A user who is in two classes on two different schools has to be set in both schools
(usermodule in tab ucs@school)

Solution

For more debugging to find the user who is effected:
This is just for admins who really know what they are doing!

/usr/share/pyshared/ucsschool/lib/schoolldap.py

root@master:~# diff -Nuar /usr/share/pyshared/ucsschool/lib/schoolldap.py{.orig-support,}
--- /usr/share/pyshared/ucsschool/lib/schoolldap.py.orig-support    2019-10-23 12:23:19.267827645 +0200
+++ /usr/share/pyshared/ucsschool/lib/schoolldap.py    2019-10-23 12:25:37.253558595 +0200
@@ -528,7 +528,10 @@
                             '&',
                             [parse(subfilter) for subfilter in search_filter_list]
                         )))
-                    ldap_objs = ldap_connection.search(search_filter, base=userdn, attr=attr)
+                    try:
+                        ldap_objs = ldap_connection.search(search_filter, base=userdn, attr=attr)
+                    except Exception:
+                        raise Exception(userdn)
                     if len(ldap_objs) == 1:
                         users.append(ldap_objs[0])
                     # else:

With UCSschool v4 the file changes where the traceback occurs:
Now it is:
/usr/lib/pymodules/python2.7/ucsschool/lib/school_umc_base.py

--- /usr/lib/pymodules/python2.7/ucsschool/lib/school_umc_base.py.orig-support	2020-06-25 10:43:27.318997444 +0200
+++ /usr/lib/pymodules/python2.7/ucsschool/lib/school_umc_base.py	2020-06-25 10:46:05.341899641 +0200
@@ -258,7 +258,11 @@
 							'&',
 							[parse(subfilter) for subfilter in search_filter_list]
 						)))
-					ldap_objs = ldap_connection.search(search_filter, base=userdn, attr=attr)
+					#ldap_objs = ldap_connection.search(search_filter, base=userdn, attr=attr)
+					try:
+						ldap_objs = ldap_connection.search(search_filter, base=userdn, attr=attr)
+					except Exception:
+						raise Exception(userdn)
 					if len(ldap_objs) == 1:
 						users.append(ldap_objs[0])
 					# else:

This could also be an issue, if there are removed students, but they are still members in their classes. So you can use
/usr/share/univention-directory-manager-tools/proof_uniqueMembers -c
to check the groupmembership consistency

Mastodon