Univention Bugzilla – Bug 51907
udm/add (users/user): AttributeError: 'NoneType' object has no attribute 'lower'
Last modified: 2020-10-14 15:28:40 CEST
Version: 4.4-5 errata712 (Blumenthal) - UCS@school 4.4 v6 Remark: Anlegen eines neuen Benutzers fehlgeschlagen Error: Interner Server-Fehler in "udm/add (users/user)". Request: udm/add (users/user) File "%PY2.7%/notifier/threads.py", line 80, in _run result = self._function() File "%PY2.7%/notifier/__init__.py", line 104, in __call__ return self._function(*tmp, **self._kwargs) File "%PY2.7%/univention/management/console/modules/udm/__init__.py", line 402, in _thread dn = module.create(properties, container=options.get('container'), superordinate=options.get('superordinate')) File "%PY2.7%/univention/management/console/modules/udm/udm_ldap.py", line 566, in create obj.create() File "%PY2.7%/univention/admin/handlers/__init__.py", line 554, in create self._ldap_pre_ready() File "%PY2.7%/univention/admin/handlers/users/user.py", line 1649, in _ldap_pre_ready if self['mailPrimaryAddress'] and self['mailPrimaryAddress'].lower() != self.oldinfo.get('mailPrimaryAddress', '').lower(): AttributeError: 'NoneType' object has no attribute 'lower' Role: domaincontroller_master
Another customer with that Traceback. Importer fails during creation of new users.
Currently, we (Daniel + Sönke) suspect that the OX-UDM hook in conjunction with a past UDM change is responsible for the traceback.
The customer asks not completely unjustified when something will happen in this regard.
See Bug #44944: Accessing a property sets the default value: >>> import univention.admin.modules >>> lo, po = univention.admin.uldap.getMachineConnection() >>> univention.admin.modules.update() >>> u = univention.admin.modules.get('users/user') >>> us = u.object(None, lo, po) >>> us.info {} >>> us['mailPrimaryAddress'] >>> us.info {'mailPrimaryAddress': None} We see that this is done in the UDM Hook for OX: /usr/lib/python2.7/dist-packages/univention/admin/hooks.d/oxAccess.py @staticmethod def check_mailaddr(module): if module['mailPrimaryAddress']: domain = module['mailPrimaryAddress'].rsplit('@')[-1] univentionAppID=oxseforucs_7.10.2-ucs3,cn=oxseforucs,cn=apps,cn=univention
Executing the following code: import univention.admin.modules lo, po = univention.admin.uldap.getMachineConnection() univention.admin.modules.update() u = univention.admin.modules.get('users/user') univention.admin.modules.init(lo, po, u) us = u.object(None, lo, po) us.open() print(us.info) We can see: {'oxLanguage': 'de_DE', 'mailPrimaryAddress': None, 'firstname': None, 'lastname': None, 'oxTimeZone': 'Europe/Berlin', 'primaryGroup': 'cn=Domain Users,cn=groups,', 'oxDisplayName': ' ()', 'isOxUser': 'Not', 'oxAccess': 'premium', 'UniventionOffice365ADConnections': []} In a regular UCS System, mailPrimaryAddress is not set after this. OX accesses the mailPrimaryAddress in hook_open(). /usr/lib/python2.7/dist-packages/univention/admin/hooks.d/oxUserDefaults.py has hook_open() which is causing this. We can see that the default for 'oxDisplayName' is '<firstname> <lastname> (<mailPrimaryAddress>)'. We can reproduce it with: /usr/lib/python2.7/dist-packages/univention/admincli/admin.py users/user create --set username=fbest --set lastname=univention --set password=univention --set mailPrimaryAddress=fbest@foobar.com The exception is triggered by `self.oldinfo.get('mailPrimaryAddress', '').lower()` A reproducer-script is in the commit message. The error has been fixed in UDM, so OX doesn't have to be adjusted: univention-directory-manager-modules (14.0.16-5) 93fc7f9d4e91 | Bug #51907: fix crash in users/user if mailPrimaryAddress property default value is set in open() univention-system-setup (8.0.2-1) r51907 | Bug #35145: Bug #35267: remove dependency and build-dependency on univention-directory-manager-modules.yaml d16b713710aa | YAML Bug #51907
Forgot to mention the technical reason: self['mailPrimaryAddress'] sets self.info['mailPrimaryAddress'] during open(). open() calls self.save() at the end, which stores self.info in self.oldinfo.
Tests: OK YAML: OK Code: OK Manual test: OK
<https://errata.software-univention.de/#/?erratum=4.4x770>