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();
}
-----
----
Solved! Go to Solution.
Views
Replies
Total Likes
Checkout https://experienceleague.adobe.com/docs/events/experience-manager-gems-recordings/gems2015/aem-oak-e... & https://experienceleague.adobe.com/docs/experience-manager-65/administering/security/ldap-config.htm...
for configuring LDAP.
Also, why do you want to write code for LDAP configuration with AEM?
Checkout https://experienceleague.adobe.com/docs/events/experience-manager-gems-recordings/gems2015/aem-oak-e... & https://experienceleague.adobe.com/docs/experience-manager-65/administering/security/ldap-config.htm...
for configuring LDAP.
Also, why do you want to write code for LDAP configuration with AEM?
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.
Views
Replies
Total Likes
Views
Likes
Replies