LDAP: How to display User's Manager information in a custom field?


Need

You want to see reporter's manager information (stored in a LDAP) in a custom field.

The “manager” attribute is a standard LDAP attribute and has a syntax of DistinguishedName (DN).
A DN uniquely identifies an entry and describes its position in the LDAP Directory information tree (eg : uid=john.doe,ou=People,dc=example,dc=com).
In a user entry, you can add the manager attribute with a value being the DN of the entry representing the manager. 



Solution

Preconditions

Have a Connect Datasource configured to your LDAP.

How to

Step 1 : Get user's manager attribute value in a Connect field

Create a Snapshot Text Connect field named "Manager DN", linked to your LDAP Datasource, which will retrieve the content of LDAP "manager" attribute of your user.

Example of LDAP Query : 

ou=people,dc=planetexpress,dc=com?manager?sub?(mail=$currentUser.emailAddress)

Editor : Read Only

Problem : 

You will get Distinguished Name of the manager, not the common name of the user which is the manager.

Eg : cn=Hermes Conrad,ou=people,dc=planetexpress,dc=com 

Step 2 : Get manager's information in an other Connect field

Create an other Connect field names "Manager", linked to your LDAP Datasource, which will retrieve the Common Name of this manager.

This field will depend on first field.

Example of LDAP Query : 

$issue.customfield_10200?cn?base?(objectClass=*)

$issue.customfield_10200  will return manager's distinguished name.

This full query will retrieve Common Name (cn attribute) of the user described via this distinguished name.

Editor : Read Only

You can now run the configuration tester to check if the configuration works.

The first field (with id: 10200 in our example) must be set on the issue selected in the configuration tester (with key CJP-7 in our example), otherwise the dependency won't be resolved.


If you want to retrieve the current reporter's manager's email, you will have to get "mail" attribute instead of cn.

Example of LDAP Query : 

$issue.customfield_10200?mail?base?(objectClass=*)

Next step ?

You can populate these fields values thanks to post-functions during creation transition.