> For the complete documentation index, see [llms.txt](https://docs.keeper.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.keeper.io/keeperpam/jp/endpoint-privilege-manager/policies/policy-examples/advanced-examples/policy-create-a-file-redirect.md).

# ポリシーのコントロール (ファイルリダイレクトの作成)

<figure><img src="/files/0gphZvRnPxIN7z6tmIJk" alt=""><figcaption></figcaption></figure>

**対象:** システム管理者

本ページでは、Keeperエンドポイント特権マネージャー (KEPM) における**ファイルリダイレクト**の構成と利用方法を取り扱います。特権昇格の要求がポリシーで**許可**された場合、リダイレクトにより**別の実行ファイルに差し替え**て起動でき、ユーザーが意図した操作を行えるようにしつつ、ポリシーで制御を維持できます。

## ファイルリダイレクトとは <a href="#what-is-a-file-redirect" id="what-is-a-file-redirect"></a>

**特権昇格**の要求がポリシーで**許可**された場合、通常は要求された実行ファイルが昇格付きで起動されます。リダイレクトはこのフローに介入し、代わりに**別の実行ファイル**を起動します。

**例:** ユーザーがPowerShell 7 (`pwsh.exe`) の昇格を要求します。ポリシーは許可しますが、リダイレクトルールはWindows PowerShell 5.1 (`powershell.exe`) に差し替えます。ユーザーは意図したシェルを利用でき、組織は昇格起動するバイナリを制御できます。

主な動作は以下のとおりです。

* リダイレクトは**特権昇格**イベントにのみ適用 (ファイルアクセスなど他のイベント種別では対象外)
* ルールに一致した場合、呼び出し元へ**DENY**が返され、代替実行ファイルが昇格付きで起動される
* リダイレクトが無効、またはルールに一致しない場合は通常の昇格フローが続行
* ポリシー評価とコントロール (MFA、正当な理由、承認) は**変更なし** (リダイレクトは要求が許可された後に実行)

リダイレクトルールは**RedirectEvaluator**プラグイン構成の `metadata.redirect` に保存されます。

## 要件 <a href="#requirements" id="requirements"></a>

<table><thead><tr><th width="245.3333740234375">要件</th><th>説明</th></tr></thead><tbody><tr><td><strong>LaunchPrivilegeElevationジョブ</strong></td><td>デプロイ済み・登録済み。RedirectEvaluator を呼び出す <code>check-redirect</code> タスクを含む</td></tr><tr><td><strong>RedirectEvaluatorプラグイン</strong></td><td>プラグイン構成に <code>metadata.redirect.enabled: true</code> と、<code>metadata.redirect.rules</code> に1件以上のルールが必要</td></tr><tr><td><strong>特権昇格ポリシー</strong></td><td>ソースアプリケーションを<strong>許可</strong>するポリシー。未設定の場合は要求が拒否され、LaunchPrivilegeElevation は実行されない</td></tr><tr><td><strong>SettingsUpdateポリシー</strong></td><td>完全な RedirectEvaluator JSON (リダイレクトルール含む) をエンドポイントへプッシュし、<code>Plugins/RedirectEvaluator.json</code> を更新</td></tr><tr><td><strong>Process Configuration Policiesジョブ</strong></td><td>ConfigurationPolicyProcessor を実行し、SettingsUpdate ポリシーの内容をプラグインファイルへ書き込み</td></tr><tr><td><strong>プラグイン設定の再読み込み</strong></td><td>JSON ファイル更新後、サービスが新しい構成を読み込む必要あり。再読み込みは <strong>UpdateSettings</strong> ポリシー、<strong>KEPM サービスの再起動</strong>、<strong>マシンの再起動</strong> のいずれか。KEPM 管理エンドポイントはターミナルやスクリプトから呼び出し不可 (呼び出し元プロセスは KEPM と同様に署名が必要)</td></tr><tr><td><strong>UpdateSettingsポリシー</strong> <em>(任意)</em></td><td>存在し前処理されると revert-all をトリガー。サービス再起動<strong>なし</strong>で設定を再読み込み</td></tr></tbody></table>

## リダイレクトルールの形式 <a href="#redirect-rule-format" id="redirect-rule-format"></a>

ルールはRedirectEvaluatorプラグインJSONの `metadata.redirect.rules` に置きます。

<table><thead><tr><th width="199">フィールド</th><th width="116">必須</th><th>説明</th></tr></thead><tbody><tr><td><strong>sourceExePattern</strong></td><td>はい</td><td><strong>実行ファイル名のみ</strong>にマッチする正規表現 (例: <code>pwsh\.exe</code>)。大文字小文字を区別しない。リテラルのドットには <code>\\.</code> を使用</td></tr><tr><td><strong>commandLinePattern</strong></td><td>はい</td><td>完全な<strong>コマンドライン</strong>にマッチする正規表現。空に不可。任意のコマンドラインには <code>.*</code> を使用</td></tr><tr><td><strong>elevationOnly</strong></td><td>はい</td><td><code>true</code> に設定 (特権昇格イベントにのみ適用)</td></tr><tr><td><strong>nonAdminOnly</strong></td><td>いいえ</td><td><code>true</code> の場合、要求ユーザーが<strong>管理者でない</strong>ときのみ適用</td></tr><tr><td><strong>targetExe</strong></td><td>はい</td><td><p>代替実行ファイル。完全な絶対パス、または製品が認識する短い名前のいずれかを指定。</p><ul><li><strong>完全な絶対パス:</strong> エンドポイント上の任意の実行ファイル (例: <code>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</code>、<code>/usr/bin/something</code>)。そのまま使用</li><li><strong>製品が認識する短い名前:</strong> パス区切りなし (例: <code>Keeper.NetworkConnections</code>)。まず <code>Jobs/bin/{name}/{name}.exe</code>、次に <code>Plugins/bin/{name}/{name}.exe</code> へ解決</li></ul><p>エンドポイント上に存在し、サービスから起動可能な実行ファイルであること</p></td></tr><tr><td><strong>targetArguments</strong></td><td>いいえ</td><td>代替側の引数 (多くの場合 <code>""</code>)。</td></tr></tbody></table>

{% hint style="info" %}
**重要:** `sourceExePattern` と `commandLinePattern` は空にできません。コマンドラインに関係なくリダイレクトするには、`commandLinePattern` に `".*"` を使います。**最初に**マッチしたルールが適用されます。具体的なルールを一般的なルールより前に置きます。

**注:** `targetExe` は Keeper のインストールツリーに限定されません。**完全な絶対パス**を指定した場合、サービスが起動できる場所であればどこでも代替実行ファイルを配置できます (例: `C:\Windows\System32\...`、`C:\Program Files\Vendor\App.exe`、`/usr/local/bin/tool`)。Jobs/bin および Plugins/bin のルックアップは、パス区切りのない**短い名前**を指定した場合にのみ適用されます。
{% endhint %}

## セットアップ <a href="#setup" id="setup"></a>

{% stepper %}
{% step %}
**特権昇格ポリシー**

リダイレクトしたいアプリケーションを**許可**するポリシーを作成します。要求が拒否されるとLaunchPrivilegeElevationは起動せず、リダイレクトは実行されません。

1. 管理コンソールまたはポリシーストアで**特権昇格**ポリシーを作成する。
2. **PolicyType**を `"PrivilegeElevation"`、**Status**を `"enabled"` に設定する。
3. **ApplicationCheck**をソース実行ファイルに一致させる (例: `PowerShell\7\pwsh.exe` を含むパス)。
4. **Controls**を昇格許可に設定する (例: `["ALLOW"]`、または必要に応じてMFA/Justify/Approvalを含める)。
5. 適切なユーザーおよびマシンコレクションに割り当て、展開/同期する。

**例 (概念上):**

```json
{
  "PolicyId": "allow-pwsh-elevation",
  "PolicyName": "Allow PowerShell 7 elevation (redirect to 5.1)",
  "PolicyType": "PrivilegeElevation",
  "Status": "enabled",
  "Controls": ["ALLOW"],
  "Filters": {
    "ApplicationCheck": { "Applications": ["*pwsh*"] }
  }
}
```

{% endstep %}

{% step %}
**SettingsUpdateポリシー (リダイレクトルール)**

このポリシーで**完全な**RedirectEvaluatorプラグインJSONを各エンドポイントの `Plugins/RedirectEvaluator.json` へプッシュします。

1. 必須フィールド (`id`、`name`、`description`、`version`、`pluginType`、`executablePath`、`Subscription`、`metadata` など) をすべて含む完全なRedirectEvaluator JSONを作成する。
2. `metadata.redirect.enabled` を `true` にし、`metadata.redirect.rules` にルールを設定する。
3. **Extension.PluginName**を `"RedirectEvaluator"`、**Extension.Action**を `"Update"`、**Extension.SettingsJson**を完全なプラグインJSONに設定した**SettingsUpdate**ポリシーを作成する。オブジェクト形式は読みやすく、エスケープミスを防ぎやすい。
4. 適切なコレクションに割り当て、展開/同期する。

**SettingsUpdateポリシーの例:**

```json
{
  "PolicyName": "Update RedirectEvaluator settings",
  "PolicyType": "SettingsUpdate",
  "Status": "enforce",
  "UserCheck": ["*"],
  "MachineCheck": ["NSBYFNaHnhkIgVIazYhFXA"],
  "ApplicationCheck": ["*"],
  "Extension": {
    "PluginName": "RedirectEvaluator",
    "Action": "Update",
    "SettingsJson": {
      "id": "RedirectEvaluator",
      "name": "Redirect Evaluator",
      "version": "1.0.0",
      "pluginType": "Executable",
      "executablePath": "../Jobs/bin/RedirectEvaluator/RedirectEvaluator.exe",
      "arguments": "--baseurl {KeeperApiBaseUrl}",
      "Subscription": { "Topic": "RedirectEvaluator" },
      "metadata": {
        "redirect": {
          "enabled": true,
          "rules": [
            {
              "sourceExePattern": "rundll32\\.exe",
              "commandLinePattern": "ncpa\\.cpl",
              "elevationOnly": true,
              "nonAdminOnly": false,
              "targetExe": "Keeper.NetworkConnections",
              "targetArguments": ""
            },
            {
              "sourceExePattern": "Notepad\\.exe",
              "commandLinePattern": "WindowsApps",
              "elevationOnly": true,
              "nonAdminOnly": false,
              "targetExe": "C:\\\\Windows\\\\notepad.exe",
              "targetArguments": ""
            },
            {
              "sourceExePattern": "WindowsTerminal\\.exe",
              "commandLinePattern": ".*",
              "elevationOnly": true,
              "nonAdminOnly": false,
              "targetExe": "C:\\\\Windows\\\\System32\\\\cmd.exe",
              "targetArguments": ""
            },
            {
              "sourceExePattern": "pwsh\\.exe",
              "commandLinePattern": ".*",
              "elevationOnly": true,
              "nonAdminOnly": false,
              "targetExe": "C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe",
              "targetArguments": ""
            }
          ]
        }
      }
    }
  }
}
```

{% hint style="info" %}
`SettingsJson` は `id`、`name`、`executablePath`、`Subscription`、`metadata` など、**完全な**プラグイン JSON である必要があります。
{% endhint %}
{% endstep %}

{% step %}
**Process Configuration Policiesの実行**

**Process Configuration Policies**ジョブ (ConfigurationPolicyProcessor) がSettingsUpdateポリシーを読み取り、各エンドポイントの `Plugins/RedirectEvaluator.json` に `Extension.SettingsJson` を書き込みます。

* **スケジュール:** 同期後、次回の実行サイクルで自動実行されます。
* **オンデマンド:** KeeperClientの**Refresh**オプションを使い、ポリシー同期と前処理を即座にトリガーします。

この手順の後、エンドポイント上のプラグインファイルにリダイレクトルールが含まれます。実行中のサービスは、設定が再読み込みされるまで (手順4) 古いメモリ上の構成を使っている場合があります。
{% endstep %}

{% step %}
**プラグイン設定の再読み込み**

プラグイン JSON ファイルを更新した後、サービスが新しい設定を読み込む必要があります。再読み込みの方法は以下のとおりです。

1. **UpdateSettingsポリシー:** ポリシー前処理時に revert-all をトリガー (手順5をご参照ください)
2. **KEPM サービスの再起動:** 起動時にディスクからプラグイン構成を読み込み。初回読み込みに最も確実
3. **マシンの再起動:** サービスの再起動と同様の効果

{% hint style="info" %}
KEPMの管理エンドポイントは、ターミナル、PowerShell、curl、その他未署名のツールからトリガーできません。
{% endhint %}
{% endstep %}

{% step %}
**任意: 再起動なしでリロードする UpdateSettings ポリシー**

1. **PolicyType**を `"UpdateSettings"`、**Status**を `"enabled"` とするポリシーを作成する。
2. 適切なコレクションに割り当て、展開/同期する。
3. KeeperPolicyがポリシーを前処理するとき、UpdateSettingsポリシーを検出し revert-all を1回呼び出します。プラグイン設定は現在のメモリ上の構成からストレージへ再インポートされます。

{% hint style="info" %}
**注:** UpdateSettingsは現在のメモリ上の構成から再インポートするだけで、ディスク上の JSON ファイルは再読み込みしません。新しい `RedirectEvaluator.json` を**初めて**プッシュするときは、サービスの再起動が最も確実です。構成が既に読み込まれている場合の再読み込みには UpdateSettings を使います。
{% endhint %}
{% endstep %}
{% endstepper %}

## 実行時の動作 <a href="#runtime-behavior" id="runtime-behavior"></a>

ユーザーがリダイレクトルールに一致する特権昇格要求をトリガーした場合は、以下の流れになります。

1. **ユーザーが昇格を要求:** 例: コマンドラインに `ncpa.cpl` を含む `rundll32.exe`
2. **ポリシー評価:** 特権昇格ポリシーが要求を許可。コントロール (MFA、正当な理由、承認) は通常どおり実行
3. **LaunchPrivilegeElevation ジョブが開始:** `metadata.redirect.enabled` が `true` のとき、`check-redirect` タスクが実行
4. **RedirectEvaluator が呼び出される:** コンテキスト (FilePath、CommandLine、IsAdmin、OriginalEventType) を渡して呼び出し。標準出力に JSON を返し、実行側がマージしてエイリアスを追加。下流タスクは `DenyOriginalRequest: true`、`RedirectTargetExe`、`RedirectTargetArgs` を参照可能
5. **ジョブが結果に応じて分岐:**
   * **send-deny-redirect:** 呼び出し元へ DENY を発行し、元の実行ファイルは起動されない
   * **launch-substitute:** 解決済みの代替パスと引数で launch-elevated へ HTTP POST
   * **send-did-elevate-response:** DidElevate を送信し、クライアントに成功を表示。ユーザーには代替アプリケーションが表示される

リダイレクトが**無効**の場合、`check-redirect` は `DenyOriginalRequest: false` を設定し、ジョブは通常のlaunch-elevatedパスを続行します。

## ターゲット実行ファイルのパス解決 <a href="#target-executable-path-resolution" id="target-executable-path-resolution"></a>

`Keeper.NetworkConnections` のような `targetExe` の値は、launch-substitute 呼び出しの前にタスク実行側によって完全パスへ解決されます。実行側は **Jobs/bin** (該当する場合は Plugins/bin) を参照します。代替起動に使われるのは、KEPM が管理する範囲内のパスのみです。

## 制限事項 <a href="#limitations" id="limitations"></a>

<table><thead><tr><th width="260">制限</th><th>説明</th></tr></thead><tbody><tr><td><strong>特権昇格のみ</strong></td><td>ファイルアクセスなど他のイベント種別では評価されない</td></tr><tr><td><strong>両方のパターンが必須</strong></td><td><code>sourceExePattern</code> と <code>commandLinePattern</code> はともに空にできない</td></tr><tr><td><strong>先にポリシーが許可している必要</strong></td><td>昇格要求はポリシーで許可されている必要あり。拒否された場合、LaunchPrivilegeElevation は実行されず、リダイレクトは評価されない</td></tr><tr><td><strong>改ざん保護</strong></td><td>初回読み込み後に <code>Plugins/RedirectEvaluator.json</code> の変更を検出した場合、ホットリロードでそのファイルの読み込みをスキップすることがある。起動時にファイルを読み込むため、KEPM サービスを再起動</td></tr><tr><td><strong>ターゲット実行ファイル</strong></td><td><code>targetExe</code> は、エンドポイント上に存在しサービスから起動可能な実行ファイルを指す必要あり。短い名前 (パス区切りなし) の場合は <code>Jobs/bin</code> または <code>Plugins/bin</code> 配下へ解決。それ以外は完全な絶対パスを指定</td></tr><tr><td><strong>最初にマッチしたルールのみ</strong></td><td>ルールは具体的なものから一般的なものへ順序付け</td></tr><tr><td><strong>UpdateSettings の範囲</strong></td><td>メモリ上の構成からの再インポートのみ (ディスク上の JSON は再読み込みしない)。一度も読み込まれていないファイルの読み込みにはサービスの再起動を使用</td></tr><tr><td><strong>ターミナル/スクリプトからの API なし</strong></td><td>管理エンドポイントは KEPM と同様に署名された呼び出し元プロセスが必要。ターミナル、PowerShell、curl からは呼び出し不可</td></tr></tbody></table>

## 関連ドキュメント <a href="#related-documentation" id="related-documentation"></a>

* [参考資料: リダイレクト](/keeperpam/jp/endpoint-privilege-manager/reference/redirect-capability.md): リダイレクト機能とルールフィールド
* [例: 設定の更新](/keeperpam/jp/endpoint-privilege-manager/policies/policy-types/advanced-policy-types/update-settings-policy-type.md): SettingsUpdateポリシーとProcess Configuration Policiesジョブ
* [参考資料: プラグインとタスクの設定](/keeperpam/jp/endpoint-privilege-manager/reference/plugin-and-task-settings.md): プラグイン設定 API、revert-all、revert


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.keeper.io/keeperpam/jp/endpoint-privilege-manager/policies/policy-examples/advanced-examples/policy-create-a-file-redirect.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
