Expand my Community achievements bar.

SOLVED

Issue with connecting Ldap api from AEM

Avatar

Level 1

I am trying to connect to ldap server using ldap api from AEM.

I am able to run the code and see the results with stand alone java but when I have the same api call in OSGI service and deployed the code in aem,seeing below error. Can some one help with solution.

org.apache.directory.ldap.client.api.exception.InvalidConnectionException: ERR_04110_CANNOT_CONNECT_TO_SERVER Cannot connect to the server: com/github/benmanes/caffeine/cache/Caffeine

 

Maven dependencies in POM:

<dependency>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-all</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>2.2.1</version>
</dependency>

 

and in bnd-mvn-plugin section CDATA:

 

-includeresource: api-all-2.1.3.jar;lib:=true,\
mina-core-2.2.1.jar;lib:=true

 

Code in osgi component:

LdapConnectionConfig config = new LdapConnectionConfig();
config.setLdapHost(providerHost);
config.setLdapPort(providerPort);
config.setName(securityPrincipal);
config.setCredentials(securityCred);

LdapNetworkConnection connection = new LdapNetworkConnection(config);
connection.connect();
connection.bind();

----

----

EntryCursor cursor = connection.search(BASE_DN, searchFilter, SearchScope.SUBTREE, returnedAttributes);
// Iterate over search results
while (cursor.next()) {
Entry attributes = cursor.get();
String cn = attributes.get("CN").get().toString();

}

-----

----

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
2 Replies

Avatar

Correct answer by
Community Advisor

Avatar

Level 1

Thank you for the response. The purpose of LDAP connection from AEM is not for login purpose, we want to fetch the employee details from LDAP server.