legacy-knowledge-base
公開されました Jul. 2, 2025

LDAPの属性がLiferayのフィールドに正しくマッピングされるように変換する。

written-by

Daniel Mijarra

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

問題

  • LDAPの属性を変換して、Liferayのフィールドと適切にマッピングする必要があります。

Environment

  • Liferay DXP 7.3

解決策

  • Liferay LDAPサーバーの設定で、LDAP属性からLiferayフィールドへのマッピングを 定義することができます。
  • 通常、これらの属性はLDAPサーバーからLiferayのフィールドに1つずつマッピングすることができ、値は直接ロードされます。 しかし、一部の値を変換しないと正しく取り込めない場合があります。
  • DefaultAttributesTransformer クラスをベースに、独自のAttributesTransformerを作成するためのモジュールを開発することができます。 ここでは、それを行うための例を紹介します:
    1. 新しいサービスモジュールを作成します(Creating-a-Custom-OSGi-Service)。
    2. 例えば、 MyOwnAttributesTransformerという新しいクラスを追加します。
    3. DefaultAttributesTransformer の内容を、以下のように自分のクラスにコピーします:
      package myownattributestransformer;

      import com.liferay.portal.kernel.security.ldap.AttributesTransformer;

      import javax.naming.directory.Attributes;

      import org.osgi.service.component.annotations.Component;

      /**
      * @author
      */

      @Component(immediate = true, property = {"service.ranking:Integer=100"}, service = AttributesTransformer.class)
      public class MyOwnAttributesTransformer implements AttributesTransformer {

      @Override
      public Attributes transformGroup(Attributes attributes) {
      System.out.println("MyOwnAttributesTransformer > Here my attributes transformations for groups");
      return attributes;
      }

      @Override
      public Attributes transformUser(Attributes attributes) {
      System.out.println("MyOwnAttributesTransformer > Here my attributes transformations for users");
      return attributes;
      }

      }
    4. Creating-a-Custom-OSGi-Service の記事にあるように、より高いサービスランキング(すなわち service.ranking:Integer=100)を定義してください。
    5. 必要に応じて、 transformGroup または transformUserの中に、あなたの属性 trasnformations を追加します。
    6. モジュールをコンパイルしてデプロイします。
did-this-article-resolve-your-issue

legacy-knowledge-base