Forums

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

Connection to ActiveDirectory with script console

Pascal Robert
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 4, 2020

Hi,

We are trying to connect to our AD forest from the script console, to ultimately able to use the same code with Behaviors or a scripted field. 

Anyway, we want to avoid copying Jars and the like, and we use groovyldap in the console, like this:

@GrabResolver(name='apache-snapshot', root='https://repository.apache.org/snapshots/')
@Grab(group='org.apache.directory', module='groovyldap', version='0.1-SNAPSHOT')

import org.apache.directory.groovyldap.LDAP

def lda_server = 'ldap://xxx.xxxx.net:389/DC=xx,DC=xx,DC=xx'
def ldap_user = 'xxx'
def ldap_password = 'xxxxxx'
def ldap = LDAP.newInstance(lda_server, ldap_user, ldap_password)
def result = ldap.searchUnique("cn=xxxx");
ldap.eachEntry ('(&(OU=xxxx,OU=xxxx))') { person ->
println "${person.displayName} (${person.cn})"
}

But sadly, we get an error 52e, and according to Atlassian doc, it means invalid credentials. But those credentials are valid when I query AD with ADBrowser.

groovyldap don't specify which auth mechanism it use, so maybe it`s using something else than simple? When using JNDI instead of grooyldap, we get this error:



javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.naming.java.javaURLContextFactory Root exception is java.lang.ClassNotFoundException: org.apache.naming.java.javaURLContextFactory
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)

Jira Server 7.11.

1 answer

0 votes
Naman Rawal
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 10, 2022

Pascal were you ever able to figure this out? Thanks

Suggest an answer

Log in or Sign up to answer