Adding an LDAP resource allows you to query your LDAP servers in a similar way to database connections.
Use an LDAP resource to:
Validate that a username provided in a custom field is a member of an LDAP group.
Write a REST endpoint to list office addresses.
In a Leavers workflow, use a post function to mark a user as having left the company.
To set up an LDAP connection, and make the connection available to scripts:
Navigate to ScriptRunner > Resources > Add New Item > LDAP Connection.
Provide a name for the connection in Pool Name.
Enter the Host.
Optionally, check Use TLS to use TLS/SSL encryption.
Enter the Port the LDAP connection is using.
Enter the base dn into the Base field.
Add the User dn.
Enter the LDAP Password.
Contact your directory services administrator for LDAP details. If you have set up an LDAP server as an application User Directory, and it’s the same LDAP server, you can copy and paste the values.
Clicking Preview validates that a successful connection and query can be made to the LDAP server.
Use LDAP Resources in Scripts
Having set up an LDAP connection, you can use it in a script as follows:
This example uses the LDAP connection with the Pool Name corporate.
LdapUtil.withTemplate takes two arguments:
The name of the connection as defined by you in the Pool Name parameter when adding the connection (in this example corporate),
A closure. The closure receives a
org.springframework.ldap.core.LdapOperationsobject as an argument.
See spring ldap for more information on querying. Where the documentation refers to an
LdapTemplate, this is equivalent to the above-mentioned