Issue with connecting Ldap api from AEM | Community
Skip to main content
May 24, 2023
Solved

Issue with connecting Ldap api from AEM

  • May 24, 2023
  • 1 reply
  • 1159 views

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();

}

-----

----

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

rawvarun
Community Advisor
rawvarunCommunity AdvisorAccepted solution
Community Advisor
May 25, 2023
GnanrdyAuthor
May 30, 2023

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.