How to do a custom LDAP query?

Hi,

For a specific requirement - a request must be approved by the requester's manager - I need to retrieve a field from Active Directory. The name of the field is easy enough, it's "manager". But I cannot find anywhere how to do a query to actually fetch that particular field for a given user.

Is this possible in the first place? The JavaDocs are a dead end, and searching with Google loads to nothing as well. Writing a custom field is not a problem, nor is accessing classes such as ComponentAccessor, UserManager or Directory. But for the actually query, I'm lost.

Thanks,

- Peter

2 answers

It is possible to write a LDAP query against Active Directory - I am doing this to retrieve a subset of available groups such that only those are available to Confluece/JIRA.

I suggest looking at this page from Microsoft: http://msdn.microsoft.com/en-us/library/windows/desktop/aa746475%28v=vs.85%29.aspx

However, I'm not sure if it is possible to do this outside of the User Directories administration area.

OK, thanks, but how exactly are you performing the query? My question was perhaps a bit unclear: what I'm trying to get is some sort of handle to a directory that I can query directly.

What I've found so far is that you can get the attributes of the Directory object for a user, which contains the LDAP/AD connection specifics, and I could use those in a JNDI query. But that seems like a somewhat inelegant solution.

Basically, to find a way to get the LDAP connection object that JIRA itself is using.

Thanks,

- Peter

I've solved it (of sorts) by getting the connection properties from the user's directory object and creating a JNDI "Context" object. Obviously, this implies a new LDAP connection every time the field is displayed, but to be honest I wouldn't know a more elegant solution.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,203 views 13 19
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot