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

Rafał Żydek April 16, 2020

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

0 votes
Joanna Choules
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.
January 20, 2021

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. @[deleted], @apuskarcik)

0 votes
Rafał Żydek April 16, 2020

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.

apuskarcik November 18, 2020

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
0 votes
Rafał Żydek April 16, 2020

@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 

Joanna Choules
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 22, 2020

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
Deleted user November 6, 2020

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
Michael Aglas November 23, 2021

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