<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>LDAP Import User Customization</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=123129156" />
  <subtitle>LDAP Import User Customization</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=123129156</id>
  <updated>2026-04-04T01:19:38Z</updated>
  <dc:date>2026-04-04T01:19:38Z</dc:date>
  <entry>
    <title>RE: LDAP Import User Customization</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=123203059" />
    <author>
      <name>Matthew Harris</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=123203059</id>
    <updated>2025-01-23T16:41:50Z</updated>
    <published>2025-01-23T10:32:12Z</published>
    <summary type="html">&lt;p&gt;Thank you so much for the help.&lt;/p&gt;</summary>
    <dc:creator>Matthew Harris</dc:creator>
    <dc:date>2025-01-23T10:32:12Z</dc:date>
  </entry>
  <entry>
    <title>RE: LDAP Import User Customization</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=123168306" />
    <author>
      <name>Zsigmond Rab</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=123168306</id>
    <updated>2025-01-06T15:42:55Z</updated>
    <published>2025-01-06T15:42:54Z</published>
    <summary type="html">&lt;p&gt;Hi Vishal,&lt;/p&gt;
&lt;p&gt;My answer may be late, however, for getting the LDAP server context
  you need the specific server and its id. For example: &lt;a href="https://github.com/liferay/liferay-portal/blob/master/modules/apps/portal-security/portal-security-ldap-impl/src/main/java/com/liferay/portal/security/ldap/internal/exportimport/LDAPUserImporterImpl.java#L541-L542"&gt;https://github.com/liferay/liferay-portal/blob/master/modules/apps/portal-security/portal-security-ldap-impl/src/main/java/com/liferay/portal/security/ldap/internal/exportimport/LDAPUserImporterImpl.java#L541-L542&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So first you need to get the LDAP server like it's done in the
  original implementation of that method: &lt;a href="https://github.com/liferay/liferay-portal/blob/master/modules/apps/portal-security/portal-security-ldap-impl/src/main/java/com/liferay/portal/security/ldap/internal/exportimport/LDAPUserImporterImpl.java#L519-L526"&gt;https://github.com/liferay/liferay-portal/blob/master/modules/apps/portal-security/portal-security-ldap-impl/src/main/java/com/liferay/portal/security/ldap/internal/exportimport/LDAPUserImporterImpl.java#L519-L526&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In the latter code, the &lt;em&gt;importUsers&lt;/em&gt; method called contains
  the first linked LDAP server context initialization.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br&gt; Zsigmond&lt;/p&gt;</summary>
    <dc:creator>Zsigmond Rab</dc:creator>
    <dc:date>2025-01-06T15:42:54Z</dc:date>
  </entry>
  <entry>
    <title>RE: LDAP Import User Customization</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=123166190" />
    <author>
      <name>Ren Prew</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=123166190</id>
    <updated>2025-01-06T17:54:58Z</updated>
    <published>2025-01-04T10:23:54Z</published>
    <summary type="html">&lt;p&gt;You can use &lt;code&gt;LDAPUtil.getContext()&lt;/code&gt; to retrieve the LDAP
  context. Pass the required parameters such as &lt;code&gt;companyId&lt;/code&gt;
  and configuration values for the LDAP server.&lt;/p&gt;</summary>
    <dc:creator>Ren Prew</dc:creator>
    <dc:date>2025-01-04T10:23:54Z</dc:date>
  </entry>
  <entry>
    <title>LDAP Import User Customization</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=123129155" />
    <author>
      <name>Vishal Karjinni</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=123129155</id>
    <updated>2024-12-20T16:46:46Z</updated>
    <published>2024-12-19T10:56:38Z</published>
    <summary type="html">&lt;h3&gt;Requirement:&lt;/h3&gt;
&lt;p&gt;While running the import interval, I want to prevent the import of
  new users from LDAP to Liferay. Instead, I only want to check the
  existing users in both LDAP and Liferay.&lt;/p&gt;
&lt;h3&gt;Implementation:&lt;/h3&gt;
&lt;p&gt;To achieve this, I have implemented the &lt;code&gt;LDAPUserImporter&lt;/code&gt;
  interface and overridden the &lt;code&gt;importUsers(long companyId)&lt;/code&gt;
  method in my custom import class. In this method, I need to obtain the
  LDAP context to perform the required operations. Could someone please
  assist with how to retrieve the LDAP context in this scenario?&lt;br&gt;
  &lt;br&gt;  &lt;/p&gt;
&lt;pre&gt;
@Override
public void importUsers(long companyId) throws Exception {
    _log.info(&amp;quot;Entering importUsers for a specific company&amp;quot;);
    _log.debug(&amp;quot;Company ID: &amp;quot; + companyId);

    // Fetch users from LDAP
    List&amp;lt;User&amp;gt; usersFromLDAP = getUsersFromLDAP(companyId);

    // Only import existing users
    for (User user : usersFromLDAP) {
        try {
            // Skip new users or deactivate users based on your custom logic
            _log.info(&amp;quot;Importing user: &amp;quot; + user.getFullName());
            _defaultLDAPUserImporter.importUser(companyId, user.getEmailAddress(), user.getScreenName());
        } catch (Exception e) {
            _log.error(&amp;quot;Error importing user: &amp;quot; + user.getScreenName(), e);
        }
    }

    _log.info(&amp;quot;Exiting importUsers for a specific company&amp;quot;);
}&lt;/pre&gt;</summary>
    <dc:creator>Vishal Karjinni</dc:creator>
    <dc:date>2024-12-19T10:56:38Z</dc:date>
  </entry>
</feed>
