Listener "printusers.py" only runs once on user-change per user

I have “printusers.py” installed and it lists the added and modified users in the UserList.txt. But when I modify a user two or more times it wont run amyore… and only runs when I add a new user.

I’m talking about this script:

even after a reboot, only newly added und removed users will be updated

Good day,

What is logged into the module log when you try to add, update and delete a user?

Best regards
Jan-Luca

somehow it doesn’t generate a module log for this module
I checked in this path:

/var/log/univention/listener_modules/

As the file doesn’t get generated… is there any way to watch the log live?

What does univention-directory-listener-ctrl status say? Is the module listed in green with status 3?

yes it is. and as I said it lists all the created / deleted users. but only lists an edit of a user once and then never again for this user…

is there another way to trace this?

Sorry, without looking further into this I am unable to point you into another direction. You could try to activate another custom listener module with the code simplified to see if the problem is specific to this module or more general happening.

I used th ehigher loglevel now… but it just doesn’t shows anything beeing run when the user was edited already:

ucr set listener/debug/level=4

it shows all the logs when the user gets freshly created, deleted or edited the first time.

It says:

 LISTENER    ( INFO    ) : handler: printusers (up-to-date)

even though there is a:

 LISTENER    ( PROCESS ) : updating 'uid=user.name,ou=mydomain.tld,dc=mydomain,dc=tld' command m

a few lines before

Looks like the module is called. As it is using the old low-level API there is a filter and attributes defined, is your changed attribute declared and does the filter include the object before/after it’s modified state?

On a side-note: Because this kind of implementation is not that easy to handle and has some historical shortcomings there is a new High-level Listener module API , if you have the time to migrate your module this would save you the hassle: 6.2. High-level Listener modules API — Univention Corporate Server - Manual for developers

Regards
Jan-Luca

it’s one out of the three oficially documented templates for module-listeners…
“does the filter include the object before/after it’s modified state” → YES.
“is your changed attribute declared” → I don’t really know… is this this line:

attributes = ['uid', 'uidNumber', 'cn']

or is the attribute inside this maybe?:

def _handle_change(dn: str, new: Dict[str, List[bytes]], old: Dict[str, List[bytes]]) -> None:

Yes, these are meant. To quote the handbook:

By default the module is called on all attribute changes of objects matching the filter. If the list is specified, the module is only invoked when at least one of the listed attributes is changed.

https://docs.software-univention.de/developer-reference/5.0/en/listener/structure.html#listener-handler

From what I read you should be able to omit the line entirely to eliminate the possibility of this to interfere.

1 Like
Mastodon