Run script on user creation / change

I would like to run a script on user-creation.
I don’t need a any varibales or anything just run the same script when a new user is created…
this way I could start user-synch on an external system, so I don’t need to wait for crontab.

running it when something changes (mostly the pw) would be great too, but not as important.

Hey,

as often, there is more than one way to do this. Regarding operations on users I would tend to write a listener module as this provides a reliable way to detect changes.
If something should run on changes of one attribute only, a UDM hook can be used, but default attributes must be extended beforehand.

Best regards
Jan-Luca

1 Like

can you provide an example how to do the listener module to run a command on user-change/creation? or is there a tutorial for dummies?
when I look at the developer-reference it seems quite complex.

As you say a listener module is not that simple as it has to capabilities to achieve various things, so there is no easier tutorial than the one provided within the developer reference, sorry.
If a small delay is ok I would advise you to just write a small idempotent script for your use case and run it via cron.

not needed anmyore → checkout my latest post.

Slightly off topic, but we ended up programming a simple web application for user management in Django that uses the UDM REST API and does all the additional stuff we need. It’s working quite well and is more flexible, but not as beautiful as the UMC of course. For us it was just much easier to use the UDM REST API than to figure out the UCS interna (listeners, hooks, …). Maybe this approach is working better for you, too?

that’s a great idea.
but rn I think when I can make this part work I’m happy with the User-Managment side.

Slightly off topic, but we ended up programming a simple web application for user management in Django that uses the UDM REST API

I am curious: have you written your own client for the UDM REST API, or did you use the PyPI package udm-rest-client (udm-rest-client · PyPI)?

1 Like

We use udm-rest-client. :slight_smile:

1 Like

Alright… it’s actually pretty easy… I’m just lost on every new subject smh till I start thinking…

copying the script → /var/lib/univention-directory-listener/handlers/ and restarting the handler-services works for installing.

adding a script to run is not much harder either… just add a line after each “Called when an object is…”-comment which runs a shell-command.

2 Likes
Mastodon