Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,630
Community Members
 
Community Events
165
Community Groups

Ldap query via Jira script runner. doesn't work. Sync extra attributes for users.

Edited

I need synchronize with LDAP few extra attributes for users.

I found that Script Runner 5.7+ you can add resources = ldap.

https://scriptrunner.adaptavist.com/latest/jira/resources.html#_ldap_connection

But I cannot run sample code to get something from LDAP.

 

My code:

import com.onresolve.scriptrunner.ldap.LdapUtil
import org.springframework.ldap.core.AttributesMapper
import javax.naming.directory.SearchControls
import javax.naming.directory.Attributes
import org.springframework.ldap.filter.AndFilter;
import org.springframework.ldap.filter.EqualsFilter;

def base="DC=ad,DC=net"
def filter="(&(objectCategory=Person)(memberOf=CN=GroupName,OU=Apps,OU=Groups,OU=Tenants,DC=ad,DC=net))"
def cnList = LdapUtil.withTemplate('users') { template ->
template.search(base,filter, SearchControls.SUBTREE_SCOPE, { Attributes attributes ->
attributes.get('cn').get()
} as AttributesMapper<String>)
}

 

Output:

[LDAP: error code 32 - 0000208D: NameErr: DSID-03100288, problem 2001 (NO_OBJECT), data 0, best match of: 'DC=ad,DC=net' ]; nested exception is javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-03100288, problem 2001 (NO_OBJECT), data 0, best match of: 'DC=ad,DC=net' ]; remaining name 'DC=ad,DC=net'

 

Base in code is the same as Base in LDAP resource entry. 

3 answers

Hi all,

We have an upcoming feature that will allow you to specify environment properties for the LDAP connection: this includes setting the referral mode. Please feel free to watch the linked development ticket and comment there with any questions.

Joanna Choules, Adaptavist Product Support

(c.c. @mittlc, @apuskarcik)

For our system configuration user directory right now is like this:

Use SSL, but in advanced section we have disabled: Secure SSL and also Fallow Referrals. I don't know how to set this via script runner resources.

Hello @Rafał Żydek , @Joanna Choules ,

Any updates on this matter? We are having a similar issue and would like to turn off Follow Referrals.

Thanks!

Like Kurt Rosivatz likes this

@Dino Carreon I saw that you done this some time ago. Right now, when I use example code:

import com.onresolve.scriptrunner.ldap.LdapUtil
import org.springframework.ldap.core.AttributesMapper
import javax.naming.directory.SearchControls
import javax.naming.directory.Attributes

def cnList = LdapUtil.withTemplate('users') { template ->
template.search("", "(sn=Smi*)", SearchControls.SUBTREE_SCOPE, { Attributes attributes ->
attributes.get('cn').get()
} as AttributesMapper<String>)
}

 I've got this error:

org.springframework.ldap.PartialResultException: Unprocessed Continuation Reference(s); nested exception is javax.naming.PartialResultException: Unprocessed Continuation Reference(s); remaining name '' at org.springframework.ldap.support.LdapUtils.convertLdapException(LdapUtils.java:216) at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:385) at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:328) at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:604) at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:594) at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:482) at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:498) at Script207$_run_closure1.doCall(Script207.groovy:7) at com.sun.proxy.$Proxy4582.apply(Unknown Source) at java_util_function_Function$apply.call(Unknown Source) at com.onresolve.scriptrunner.ldap.DefaultLdapConnectionManager.withTemplate(DefaultLdapConnectionManager.groovy:41) at com.onresolve.scriptrunner.ldap.LdapConnectionManager$withTemplate$1.callCurrent(Unknown Source) at com.onresolve.scriptrunner.ldap.DefaultLdapConnectionManager.withTemplateTracked(DefaultLdapConnectionManager.groovy:48) at com.onresolve.scriptrunner.ldap.LdapConnectionManager$withTemplateTracked$0.call(Unknown Source) at com.onresolve.scriptrunner.ldap.LdapUtil.withTemplate(LdapUtil.groovy:13) at Script207.run(Script207.groovy:6) Caused by: javax.naming.PartialResultException: Unprocessed Continuation Reference(s); remaining name '' at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source) at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source) at com.sun.jndi.ldap.AbstractLdapNamingEnumeration.getNextBatch(Unknown Source) at com.sun.jndi.ldap.AbstractLdapNamingEnumeration.hasMoreImpl(Unknown Source) at com.sun.jndi.ldap.AbstractLdapNamingEnumeration.hasMore(Unknown Source) at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:365) ... 14 more

 

Can you help me with this?

Or you @Joanna Choules 

Hi Rafał,

This Stack Overflow post suggests a couple of ways to resolve this error: changing the port number can be done by editing the config of your LDAP connection in the Resources tab, while changing the referral mode is currently not supported but I will raise it as a request with our development team.

Best wishes,

Joanna Choules, Adaptavist Product Support

Like Cael Metcalfe likes this

Hello @Joanna Choules ,

are there any news on the integration of the referral mode?

And alternatively:
Is there a way of setting the Adaptavist Script Runner Config to this property as this is another suggested fix for the Partial Exception Error?

ignorePartialResultExcepton = true


Best,

Clemens

Like Kurt Rosivatz likes this

I think this is because, there is no account starting with 'Smi' available or just a single one. I don't know how to cope with this one...

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
Community showcase
Published in Jira Software

Upcoming changes to epic fields in company-managed projects

👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...

14,117 views 34 44
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you