Bug 51812 - univention-directory-report: execute script instead of template to create a report
univention-directory-report: execute script instead of template to create a r...
Status: RESOLVED MOVED
Product: UCS
Classification: Unclassified
Component: UMC - Reports
UCS 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: UMC maintainers
UMC maintainers
https://git.knut.univention.de/univen...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-08-12 14:39 CEST by Lukas Zumvorde
Modified: 2021-11-12 13:17 CET (History)
2 users (show)

See Also:
What kind of report is it?: Feature Request
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?: Yes
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Usability
Max CVSS v3 score:
best: Patch_Available+


Attachments
patch draft (fbest/51812-univention-directory-reports-script) (4.09 KB, patch)
2020-08-12 17:08 CEST, Florian Best
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Zumvorde univentionstaff 2020-08-12 14:39:52 CEST
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.
Comment 1 Florian Best univentionstaff 2020-08-12 17:08:31 CEST
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
Comment 2 Lukas Zumvorde univentionstaff 2020-08-13 10:22:00 CEST
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.