Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Get the value for an active directory attribute field using Script Runner

Khushbu Jowaheer April 3, 2018

Hello All,

 

There are some attributes that I am retrieving from Active Directory using Active Directory Attributes Sync 2 addon.

When I create an issue in JIRA, I am able to display the attribute details such as contact number, Department in the issue details screen. Now I want to write a server side script using script runner behaviour to get the value of the contact number and paste that value in another custom field of type text in JIRA. Is it possible to do so?

If it is, can you please assist me how to get this done?

Thanks.

Khushbu

1 answer

1 vote
Knut Arne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 3, 2018

Hi,

I was able use the information from the following site (example on the bottom) to show a reporters phonenumber in a customfield: https://deviniti.com/support/addon/server/active-directory/latest/using-synchronized-data-in-script-runner/

import com.atlassian.Jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.intenso.Jira.plugins.admanager.util.ActiveDirectoryAttributeManager

@WithPlugin("com.intenso.Jira.plugins.ad-integration-manager")

def activeDirectoryAttributeManager = ComponentAccessor.getOSGiComponentInstanceOfType(ActiveDirectoryAttributeManager.class)
def userManager = ComponentAccessor.getUserManager()

def reporteruser = myIssue.getReporter()
def user = userManager.getUserByKey(reporteruser)

def userAttributeMap = activeDirectoryAttributeManager.getUserAttributes(user, "myActiveDirectory") //get Map of user Attibutes for connection "myActiveDirectory"
def telephoneNumber = userAttributeMap.get("Telephone Number") //get Attribute from Map`

return telephoneNumber

Hope this will help.

Suggest an answer

Log in or Sign up to answer