> For AI agents: the complete documentation index is available at /resource/ucidm/docs/on-premise/1.8.0/llms.txt, the full documentation bundle is available at /resource/ucidm/docs/on-premise/1.8.0/llms-full.txt.

# 外部連携の前処理/後処理で実行するスクリプトの配置

各外部連携処理の前後で任意のシェルスクリプトを実行することができます。

シェルスクリプトには、第一引数に以下の情報が渡されます。

```
{
	"DN":"uid=ucidmldaptest1,ou=users,dc=srcldap,dc=com",
	"Attributes":{
		"cn":["UCIDMTest1"],
		"givenname":["Taro"],
		"mail":["ucidmtest1@example.com"],
		...
	},
	"Password": "password",
	"Member": {
        "primaryID": "ucidm-5-csvtestuser101",
        "entry": {
            "dn": "uid=csvtestuser101,ou=users,dc=srcldap2,dc=example,dc=com",
            "attributes": {
                "cn": ["test101-cn"],
                "description": ["test101-desc"],
                "givenname": ["test101-given"],
		        ...
            },
		},
    },
	"EntryDiff":[
		{
			"sourceNames":["sn"],
			"destinationName":"surname",
			"sourceValue":["test1sn"],
			"previousValue":["test1"],
			"currentValue":["test1"]
		},
		...
	]
}
```

- DN : UCIDM に連携されてきたエントリの DN 情報
- Attributes : UCIDM に連携されてきたエントリの属性名と属性値の情報
- Password : ユーザーパスワード更新時に、ENABLE_SCRIPT_PASSWORD の環境変数が true に設定されている場合のみシェルスクリプトにて取得可能で、更新されたパスワードの情報が入っている
- Member : グループメンバー追加/削除時にのみシェルスクリプトのみで取得可能で、グループのメンバーエントリの情報が入っている
- EntryDiff： 外部連携処理の後に呼ばれるシェルスクリプトのみで取得可能で、連携における差分の情報が入っている

シェルスクリプトにおける終了コード 0 以外はエラーとして UCIDM で処理されます。

シェルスクリプトは、各処理種別ごとに、以下のディレクトリ上に格納する必要があります。また、スクリプトファイルには実行権限をつける必要があります。

- ユーザ追加
  - /var/opt/osstech/lib/ucidm/server-data/destination/`{DESTINATION_ID}`/scripts/UserAdded/
- ユーザ更新
  - /var/opt/osstech/lib/ucidm/server-data/destination/`{DESTINATION_ID}`/scripts/UserModified/
- ユーザ削除
  - /var/opt/osstech/lib/ucidm/server-data/destination/`{DESTINATION_ID}`/scripts/UserDeleted/
- ユーザパスワード更新
  - /var/opt/osstech/lib/ucidm/server-data/destination/`{DESTINATION_ID}`/scripts/UserPasswordModified/
- グループ追加
  - /var/opt/osstech/lib/ucidm/server-data/destination/`{DESTINATION_ID}`/scripts/GroupAdded/
- グループ更新
  - /var/opt/osstech/lib/ucidm/server-data/destination/`{DESTINATION_ID}`/scripts/GroupModified/
- グループ削除
  - /var/opt/osstech/lib/ucidm/server-data/destination/`{DESTINATION_ID}`/scripts/GroupDeleted/
- グループメンバー追加
  - /var/opt/osstech/lib/ucidm/server-data/destination/`{DESTINATION_ID}`/scripts/GroupMemberAdded/
- グループメンバー削除
  - /var/opt/osstech/lib/ucidm/server-data/destination/`{DESTINATION_ID}`/scripts/GroupMemberDeleted/

上記ディレクトリ上にシェルスクリプトを配置することで、外部連携設定画面にて、シェルスクリプトの指定が可能になります。

外部連携設定画面での設定については、以下のページをご参照ください。

[外部連携の前処理/後処理で実行するスクリプトの設定](/resource/ucidm/docs/on-premise/1.8.0/administration/admin-ui/scriptsettings.md)
