Hello,
ich have developed a custom directory listener following the documentation I found here (https://wiki.univention.de/index.php?title=Entwicklung_von_Univention_Directory_Listener-Modulen) and here (https://www.univention.de/blog-de/2017/06/sync-und-kontrolle-aller-aenderungen-im-openldap-ueber-listener-module/)
The code is as follows:
__package__ = "" # workaround for PEP 366
import univention.debug as ud
import requests
name = "test"
description = "test module"
filter = '''\(|(&(objectClass=posixAccount)(objectClass=shadowAccount))(objectClass=univentionMail)(objectClass=sambaSamAccount)(&(objectClass=person)(objectClass=organizationalPerson)(objectClass=inetOrgPerson)))'''
attributes = ["givenname", "employeenumber"]
def handler(dn, new, old):
try:
if new and old:
_handle_change(dn, new, old)
elif new and not old:
_handle_add(dn, new)
if old and not new:
_handle_remove(dn, old)
finally:
pass
def _handle_add(dn, new):
# if a user is created
ud.debug(ud.LISTENER, ud.ERROR, 'user created')
def _handle_change(dn, new, old):
# if a user is changed
ud.debug(ud.LISTENER, ud.ERROR, 'user changed')
def _handle_remove(dn, old):
# if a user is deleted
ud.debug(ud.LISTENER, ud.ERROR, 'user deleted')
Basically, this code is working, but only as long as I keep the attributes array empty. With the values given in the code, the script is never executed, no matter what user property I change.
Can anyone tell me what I am doing wrong?
Important: the documentation in the second link (see top) has an error:
name = "web_connector"
description = "Der Web-Connector spricht eine Web-API an."
filter = "(objectClass=ucsschoolTeacher)"
attribute = ["ucsschoolSchool", "departmentNumber:"]
Note the “attributes” property is “attribute” there, which is wrong.
Thanks in advance!
Kind regards, Tom