# Windows資格情報マネージャー

<figure><img src="/files/WisQT7nM461w2U3YUek8" alt=""><figcaption></figcaption></figure>

## 概要 <a href="#overview" id="overview"></a>

Windows資格情報マネージャーはネイティブのWindowsユーティリティで、パスワードやシークレットなどの機密情報を保存し、アプリケーションが安全にアクセスできるようにします。

KeeperではWindows資格情報ユーティリティを用意しており、このユーティリティを使用してネイティブWindows APIと連携し、Windows資格情報マネージャーのシークレットを保存および取得できます。また、あらゆる統合、プラグイン、コードベースで使用でき、Windows資格情報マネージャーの資格情報、シークレット、パスワードをシンプルかつネイティブに保存および取得できます。

Windows資格情報ユーティリティのコードベースは、以下の場所にあります。

{% embed url="<https://github.com/Keeper-Security/windows-credential-utility>" %}

上記のユーティリティを使用するために必要なバイナリは、以下の場所にあります。

{% embed url="<https://github.com/Keeper-Security/windows-credential-utility/releases>" %}

Windows資格情報ユーティリティを使用するには、以下のいずれかを実行します。

* [リリースページ](https://github.com/Keeper-Security/windows-credential-utility/releases)からビルド済みのバイナリをデプロイする
* コードベースにインポートする

両方の使用例について以下で説明します。

## 使用方法 - 実行ファイル <a href="#usage-executable" id="usage-executable"></a>

### 実行ファイルのダウンロード <a href="#downloading-the-executable" id="downloading-the-executable"></a>

[リリースページ](https://github.com/Keeper-Security/windows-credential-utility/releases)から最新バージョンの実行ファイルをダウンロードし、必要に応じてPATHに追加して開始します。

### 実行ファイルの使用 <a href="#using-the-executable" id="using-the-executable"></a>

実行ファイルで2つのコマンドがサポートされています。

1. `set`
2. `get`

どちらのコマンドも、最初の引数としてアプリケーション`name` (Windows資格情報マネージャーに保存される資格情報の名前) が必要です。

#### `set` <a href="#set" id="set"></a>

`set`では保存するシークレットの2番目の引数が必要となり、以下のいずれかとなります。

1. BASE64文字列
2. JSON文字列
3. 既存のJSONファイルへのパス

シークレットが Windows資格情報マネージャーに保存される際、まずBASE64形式にエンコードされます (まだ BASE64 文字列でない場合)。これにより保存形式が標準化され、Keeperの統合機能および製品での利用が容易になります。

#### `get` <a href="#get" id="get"></a>

`get`は、保存されているBASE64でエンコードされた構成を`stdout`に返し、`0`の終了コードで終了します。要求元の統合では、出力をキャプチャして使用できます。構成の取得中にエラーが発生した場合、`non-zero`の終了コードが返され、`stderr`に書き込まれます。

### 例 <a href="#example" id="example"></a>

```
# シークレットを保存
wcu set APPNAME eyJ1c2VybmFtZSI6ICJnb2xsdW0iLCAicGFzc3dvcmQiOiAiTXlQcmVjaW91cyJ9
# or
wcu set APPNAME config.json

# シークレットを取得
wcu get APPNAME
```

## 使用方法 - コードベースへのインポート <a href="#usage-importing-it-into-your-codebase" id="usage-importing-it-into-your-codebase"></a>

このユーティリティは、Nuget経由でコードベースにインストールできます。

```
dotnet add package Keeper.WindowsCredentialManager
```

以下のように、コードベースにインポートできます。

```
using WindowsCredentialManager
```

### `set` <a href="#set-1" id="set-1"></a>

Windows資格情報マネージャーに書き込むには、`CredentialManager`オブジェクトの`WriteCredential`メソッドを使用できます。これにより、現在のユーザーの資格情報マネージャーのシークレットが書き込まれ、上書きされます。

資格情報マネージャーにシークレットを正常に追加するには、3つの引数を指定する必要があります。

まず、アプリケーション名 (シークレットの参照に使用)、ユーザーのユーザー名の文字列表現、シークレット自体で、以下のいずれかになります。

1. BASE64文字列
2. JSON文字列
3. 既存のJSONファイルへのパス

シークレットが Windows資格情報マネージャーに保存される際、まずBASE64形式にエンコードされます (まだ BASE64 文字列でない場合)。これにより保存形式が標準化され、Keeperの統合機能および製品での利用が容易になります。

```
var secret = Parsing.ParseConfig(configArg); // Returns a BASE64 sring
CredentialManager.WriteCredential("MY_APP_NAME", Environment.UserName, secret);
```

### `get` <a href="#get-1" id="get-1"></a>

資格情報マネージャーからシークレットを取得するには、アプリケーション名を`ReadCredential`メソッドに渡します。これにより、保存されているBASE64でエンコードされたシークレットが返されます。

```
var cred = CredentialManager.ReadCredential("MY_APP_NAME");
```


---

# Agent Instructions: 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:

```
GET https://docs.keeper.io/jp/keeperpam/secrets-manager/integrations/windows-credential-manager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
