掲示板

Access LDAP Directory structure in Liferay DXP

6年前 に Durga prasada Rao Kasina によって更新されました。

Access LDAP Directory structure in Liferay DXP

New Member 投稿: 21 参加年月日: 12/07/26 最新の投稿
I am trying to export data from excel to LDAP from Liferay 7 Portlet. I believe below are the steps to be followed:
1. Connect to LDAP which i need to write code in my Portlet class
2. After successful connection, write code to access the directory structure
3. migrate the data from excel to LDAP

Can anybody, help me with gradle configurations and sample code.
thumbnail
6年前 に Olaf Kock によって更新されました。

RE: Access LDAP Directory structure in Liferay DXP

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
Durga prasada Rao Kasina:
I am trying to export data from excel to LDAP from Liferay 7 Portlet. I believe below are the steps to be followed:
1. Connect to LDAP which i need to write code in my Portlet class
2. After successful connection, write code to access the directory structure
3. migrate the data from excel to LDAP

Can anybody, help me with gradle configurations and sample code.


If you just want to authenticate against LDAP (which will import the data during login or scheduled) you might not need to write any code. If you want to access LDAP, you're doing this just like in any other place, using LDAP APIs. Not sure what your requirements are.
6年前 に Durga prasada Rao Kasina によって更新されました。

RE: Access LDAP Directory structure in Liferay DXP

New Member 投稿: 21 参加年月日: 12/07/26 最新の投稿
Hi,

Thank you for quick turn around.
I am using the below code and with main method it is working as expected but when i am using it with liferay 7 portlet class, getting classcast exception com.sun.jndi.ldap.LdapCtxFactory

Sample code:
String url = "ldap://localhost:389";
String conntype = "simple";
String AdminDn = "cn=manager,dc=maxcrc,dc=com";
String password = "secret";
Hashtable<String, String> environment = new Hashtable<String, String>();

environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
environment.put(Context.PROVIDER_URL, url);
environment.put(Context.SECURITY_AUTHENTICATION, conntype);
environment.put(Context.SECURITY_PRINCIPAL, AdminDn);
environment.put(Context.SECURITY_CREDENTIALS, password);

dirContext = new InitialDirContext(environment);

I have used jndi-1.2.1.jar

Could you pls. tell me what is the Context_factory i need to use
thumbnail
6年前 に Christoph Rabel によって更新されました。

RE: Access LDAP Directory structure in Liferay DXP

Liferay Legend 投稿: 1555 参加年月日: 09/09/24 最新の投稿
Since Liferay also uses ldap, I guess it already has that jar included and you get some kind of version mismatch.

Take a look at the liferay code that does ldap, maybe it helps:
https://github.com/liferay/liferay-portal/blob/1f068c7d00607e4acf382b8db11d370412e1fa91/modules/apps/foundation/portal-security/portal-security-ldap/src/main/java/com/liferay/portal/security/ldap/internal/exportimport/LDAPUserImporterImpl.java
6年前 に Durga prasada Rao Kasina によって更新されました。

RE: Access LDAP Directory structure in Liferay DXP

New Member 投稿: 21 参加年月日: 12/07/26 最新の投稿
Thank you.

I already checked this but when i am trying to import this package in my class where i am writing to get LDAP connection, getting errors
import com.liferay.portal.security.ldap.internal.exportimport;

Error: The import com.liferay.portal.security cannot be resolved.

By the way i am using Liferay 7.0 (DXP) and Gradle. Could you pls. let me know whether it is required to add any dependencies to get this package. I believe not required because it is part of liferay. Kindly help
thumbnail
6年前 に Christoph Rabel によって更新されました。

RE: Access LDAP Directory structure in Liferay DXP

Liferay Legend 投稿: 1555 参加年月日: 09/09/24 最新の投稿
If the goal is just to get the excel data into ldap (once), why go through the portal?
Export them to csv, convert it to ldif and import it. (I tried a quick search for "csv to ldif" and there are several hits that might be helpful).