ロールマッパー

最終公開日 : Sep 28, 2026

はじめに

ロールマッパースクリプトは、IDプロバイダーからの外部ロールを、同期ディレクトリ機能の一部として、内部EBX®ロールにマッピングするための柔軟なアプローチを提供します。
ロールマッパースクリプトを作成、変更、および公開するには、EBX® Script IDEを使用します。

設定

ロールマッパースクリプトは、ebx.properties の同期ディレクトリセクションで設定されます。
# Enable synchronized directory
ebx.directory.synchronized.source=LDAP
...

# Set role mapper to use scripts
ebx.directory.synchronized.role.mapper=SCRIPT

初期スクリプト

EBX® Script IDEを使用してロールマッパースクリプトが初めて編集されると、EBX®はエクスポートされた関数の正しい定義を含む初期スクリプトを提供します。
初期ロールマッパースクリプトは次の構造を持ちます。
<unit usage statement 1>
<unit usage statement 2>
...
<unit usage statement N>

export function mapRoles(userAttributes: unmodifiable dictionary<set<string>>,
                        externalRoles: unmodifiable set<string>): set<profile>
begin
  ...
  <statement 1>
  <statement 2>
  ...
end
以下の例は、基本的なロールマッパースクリプトです。
uses core.set as set;
uses core.profile as profile;

export function mapRoles(userAttributes: unmodifiable dictionary<set<string>>,
                        externalRoles: unmodifiable set<string>): set<profile>
begin
    var result := set.of<profile>();

    // Map external admin role to built-in administrator
    if set.contains(externalRoles, 'admin') then
    begin
        set.add(result, profile.ofAdministrator());
    end

    return result;
end

関数シグネチャ

mapRoles 関数は次のシグネチャを持つ必要があります。
export function mapRoles(userAttributes: unmodifiable dictionary<set<string>>,
                        externalRoles: unmodifiable set<string>): set<profile>

パラメーター

  • userAttributes : IDプロバイダーからのユーザー属性を含む辞書。各キーは属性名であり、各値は属性値を表す文字列のセット
    例: {'department': {'IT', 'Engineering'}, 'location': {'Paris'}, 'title': {'Senior Developer'}}
  • externalRoles : IDプロバイダーによってユーザーに割り当てられた外部ロールのセット
    例: {'admin', 'developer', 'manager'}

戻り値

この関数は、ユーザーに割り当てられる内部ロールを表す** profile**オブジェクトのセットを返す必要があります。
注: 関数が空のセットを返した場合、ユーザーにはロールが割り当てられません。

利用可能な関数

以下のプロファイル関数は、core.profile ユニットを使用して利用できます。
  • profile.ofAdministrator() : 組み込みの管理者プロファイルを返します
  • profile.ofReadOnly() : 組み込みの読み取り専用プロファイルを返します
  • profile.ofOwner() : 組み込みの所有者プロファイルを返します
  • profile.ofEveryone() : 組み込みの全員プロファイルを返します
  • profile.forSpecificRole(roleName) : 指定された名前の特定のロールプロファイルを返します

例

基本的なロールマッピング

この例は、外部ロールを内部EBX®プロファイルに直接マッピングする方法を示します。
uses core.set as set;
uses core.profile as profile;

export function mapRoles(userAttributes: unmodifiable dictionary<set < string >>,
externalRoles: unmodifiable set<string>): set<profile>
begin
    var result := set.of<profile>();

    // Map external admin role to built-in administrator
    if set.contains(externalRoles, 'external_admin') then
        set.add(result, profile.ofAdministrator());

    // Map external read role to built-in read-only
    if set.contains(externalRoles, 'external_reader') then
        set.add(result, profile.ofReadOnly());

    return result;
end

属性ベースのロールマッピング

この例は、ユーザー属性(部署など)を使用してロールの割り当てを決定する方法を示します。
uses core.dictionary as dict;
uses core.set as set;
uses core.profile as profile;

export function mapRoles(userAttributes: unmodifiable dictionary<set < string >>, externalRoles: unmodifiable set<string>): set<profile>
begin
    var result := set.of<profile>();

    // Get user department from attributes
    var departments := dict.get(userAttributes, 'department');

    if isNull(departments) then
        return result;

    if set.contains(departments, 'IT') then
        set.add(result, profile.ofAdministrator());

    if set.contains(departments, 'HR') then
        set.add(result, profile.forSpecificRole('HR_Manager'));

    return result;
end

トラブルシューティング

スクリプトが実行されない場合:
  • ebx.properties で ebx.directory.synchronized.role.mapper=SCRIPT が設定されていることを確認します
  • スクリプトがEBX® Script IDEで公開され、アクティブであることを確認します
  • ランタイムエラーがないかスクリプトログを確認します