# JXWorkBench Reporting

JXWorkBench allows you to create reports from your directory data, and save them in a wide variety of formats, including .pdf, .docx, .html and .xml . These reports can be run manually, or run in batch mode as a script.

## Reporting Templates

JXWorkBench uses the Jasper open source reporting system, and new reports can be easily written either directly, or using Jasper's iReports graphical report creation tool (http://ireports.com).

(Note that the iReports tool is optimised to work with relational databases, not directories, and some functionality is not available; in particular you will need to know what attributes you want to use in advance, as iReports cannot interrogate the directory to discover them.)

JXWorkBench provides a number of starting reports 'out of the box' to do a number of basic user reports such as:

- Users created today, this week, this month, this year
- Users modified today, this week, this month, this year
- Users by org unit
- Users by group
- User Groups created today, this week, this month, this year
- User Groups modified today, this week, this month, this year

## Adjusting the LDAP query

These reports can be simply modified by changing the query parameter in the report. The query parameter has two parts; an ldap 'query' string, which specifies the search query used to select entries to report on, and the base DN, which specifies where to search from. E.g. this query block lists all users under the 'c=au' branch of the tree:

    <queryString language="ldap"> <![CDATA[filter=(objectClass=person)):c=au]]> </queryString>

In addition to normal directory attributes, some special date values are pre-calculated as a convenience: $P{day_prior}, $P{week_prior}, $P{thirty_days_prior}, $P{year_prior}. E.g. this query lists all users who have been added in the last day:

    <queryString language="ldap"> <![CDATA[filter=(&(objectClass=person)(createTimeStamp>=$P{day_prior})):dn=c=au]]> </queryString>

## Reporting Options

Reports can be viewed directly in the browser, or exported to Adobe pdf documents, Microsoft word documents, Microsoft Powerpoint, HTML web pages, RTF documents or generic XML.

The reports are written to the 'output directory' specified in the main window.

## Batch Processing

Once a report has been setup in JXWorkBench it can also be run as a batch job from a command line script, using your saved report details and a saved connection. In this way batch reports can be generated from your directory data with little effort; e.g.

        java -classpath ".;jars/*;jasper/lib/*" com.ca.directory.jxplorer.JXplorer -report -template test_batch -con localhost

Usage information is available using options "-report -help".

## Available Data Fields

The report works through the list of directory entries specified in the search query, and all the attributes of those entries are available as Jasper data fields. In addition, synthetic attributes for the distinguished name ('dn'), the parent distinguished name ('parentdn') and relative distinguished name ('rdn') are provided.

(Note: the Jasper reporting language requires you to pre-define the attributes you are going to use; see the 'field definitions' at the top of the file for examples.)

### Special Attributes

The following are 'artifical' attributes, that are not strictly attributes of the entry, but can still be very useful. Effectively we treat the name of the entry as another attribute, and provide some name related derivative values.

attribute | purpose
--- | ---
dn | gives the full distinguished name of the entry
parentdn | gives the parent entry dn, and can be used for indirection (see 'following DN links' below)
rdn | the local name; eg 'uid=cb99'
rdn.attid | the local naming attribute; e.g. 'uid'
rdn.attval | the local naming value; e.g. 'cb99'

## Advanced Reporting - following DN links

JXWorkBench allows you to 'follow' DN attributes and include fields from the followed entry. For example, if a particular user entry has a DN link to a group, e.g. 'groupdn', the report can follow this dn to find an attribute of the linked group (e.g. 'groupdn.description' will read the group entry from the dn, and then look for a 'description' attribute).

The same method can be used to report on group member information; see the sample 'users by group' report, where the member attribute value is used as a link to the user entry, allowing us to print out the user name rather than the user DN:

## Advanced Reporting - multi-valued attributes

Where an entry has a multivalued attribute which is being printed in a report, the entry will be echoed across multiple lines. The report will keep printing new lines as long as it has fresh values to print, however it will print blamks for values if it 'runs out' of attribute values for some attributes before others.

## Sample Reports

A large number of sample reports are available in the JXWorkBench /reports directory, or from the jxplorer.org downloads page.

## Commercial Support

Support with writing custom reports is available through Pegacat Software: email jxworkbench@pegacat.com .