Univention Bugzilla – Bug 51812
univention-directory-report: execute script instead of template to create a report
Last modified: 2021-11-12 13:17:56 CET
Overview: --------- It is not possible to create reports with entries generated from object being referenced by anything else but complete DNs Description: ------------ A customer had a request for some directory CSV reports with specific requirements. Those could not be created with the given capabilities of the report templates. Here is a simplified example: The following objets are in UDM Module Users/user DN: uid=test222,ou=ou2,ou=firma,dc=ucs,dc=sbvg,dc=ch syncId: 1 username: test222 Module container/ou DN: ou=ou2,ou=firma,dc=ucs,dc=sbvg,dc=ch name: ou2 syncId: 1 We want to create a CSV-Report about the users. It has the format company username - username is the uid of the user - company is the name of the container with the same syncId as the user. We can not assume that the user object is located beneath the container, and thus we can not read the company from the DN of the user. Suggestion: ----------- To solve this problem we could extend the capabilities of the report templates, but it would possibly be easier and more flexible to allow the execution of a user defined script, that gets the DNs of the object being selected for the report as command line arguments and that creates the report on its own. It would be useful to be able to include this script using UCR just like one can include the regular report templates.
Created attachment 10461 [details] patch draft (fbest/51812-univention-directory-reports-script) Hmm. One idea is this patch draft, which works: ucr set directory/reports/templates/py/user1='users/user "My Custom Report" /etc/univention/directory/reports/default users.py' $ cat /etc/univention/directory/reports/default/en_US/users.py #!/usr/bin/python import sys print('foo', sys.argv) $ chmod +x /etc/univention/directory/reports/default/en_US/users.py $ ln -s /etc/univention/directory/reports/default/en_US/users.py /etc/univention/directory/reports/default/de_DE/users.py
The patch looks really promising to me. The configuration is in line with the other kinds of reports and would give all the flexibility needed.