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

API経由で登録したユーザのパスワードとパスワードポリシーの適用について

written-by

Shimada Taro

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

問題

  • ユーザーをAPI経由で登録しています。
  • パスワード、パスワードポリシーはどのような値が設定されますか。

環境

  • DXP 7.4

解決

  • APIでユーザーを登録時にパスワードを指定しない場合、自動生成されたパスワードが設定されます。
    関連ソースコード:UserLocalServiceImpl.java
  • パスワードポリシーは、「Default Password Policy」が適用されます。

追加情報

  • ①ヘッドレスREST API
    「http://localhost:8080/o/api」へアクセスし、UI上から実行した際のサンプル。
    API:
    http://localhost:8080/o/headless-admin-user/v1.0/openapi.json
    UserAccount
    POST /v1.0/user-accounts
    {
    "alternateName": "user1",
    "birthDate": "1970-01-01T00:00:00Z",
    "customFields": [],
    "emailAddress": "user1@liferay.com",
    "familyName": "1",
    "givenName": "user",
    "password": "test",
    "name": "1 user"
    }
  • ②JSON API
    「http://localhost:8080/api/jsonws」から「/user/add-user」を使用してユーザー登録を行った際のcurlサンプル。
    curl http://localhost:8080/api/jsonws/user/add-user \
    -u test@liferay.com:test \
    -d companyId=20098 \
    -d autoPassword=true \
    -d password1='test' \
    -d password2='test' \
    -d autoScreenName=true \
    -d screenName='user1' \
    -d emailAddress='user2@liferay.com' \
    -d locale=ja_JP \
    -d firstName='1' \
    -d middleName='' \
    -d lastName='user' \
    -d prefixId=0 \
    -d suffixId=0 \
    -d male=true \
    -d birthdayMonth=1 \
    -d birthdayDay=1 \
    -d birthdayYear=2020 \
    -d jobTitle='' \
    -d groupIds= \
    -d organizationIds= \
    -d roleIds= \
    -d userGroupIds= \
    -d sendEmail=true
did-this-article-resolve-your-issue

legacy-knowledge-base