> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Processing Monitor のセキュリティ イベント ログ

> ABBYY FlexiCapture Processing Monitor の権限変更に関するセキュリティ イベント ログを、スクリプトを使用して GetSecurityEventsCSV POST request 経由で CSV としてダウンロードします。

このログには、ユーザー権限の追加、削除、その他の変更に関連するイベントが記録されます。セキュリティ イベントのログ記録は既定では無効になっており、FlexiCapture データベースでシステム管理者のみが直接有効にできます。詳しくは、[セキュリティ イベント ログ](/ja/flexi-capture/web-stations/monitoring-console/mmc-security-event-log) を参照してください。

<Warning>
  Processing Monitor からセキュリティ イベント ログをダウンロードできるのは、テナント管理者 (デフォルト テナントの場合はシステム管理者) のみです。
</Warning>

このログをダウンロードするには、POST リクエストを使用します:

```http theme={null}
POST https://<server address>/FlexiCapture12/Monitoring/Project/GetSecurityEventsCSV
```

<div id="request-parameters">
  ## リクエストパラメーター
</div>

すべてのパラメーターは必須です。正しく指定されていることを確認してください。

<Info>
  Oracle Database では、検索で大文字と小文字が区別されます。Oracle Database を使用する場合は、この点に注意してください。
</Info>

| パラメーター            | 型      | 説明                                                                                                                                              |
| ----------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `filter`          | string | ログのフィルター条件です。条件を組み合わせる場合は、`GeneralOperator` パラメーターで指定する `AND` 演算子と `OR` 演算子のみを使用します。詳細は、[フィルターパラメーターの作成](#build-the-filter-parameter)を参照してください。 |
| `columnsOrder`    | string | レポートに含める列のカンマ区切りリスト: `ID`, `Date`, `EventType`, `Details`, `RemoteHost`, `Principal`, `TenantName`, `Writer`, `WriterTenantName`。               |
| `sortColumnindex` | int    | ログ内のレコードを並べ替える際に使用する列のインデックスです。                                                                                                                 |
| `sortOrder`       | bool   | 並べ替え順です。`true` は降順、`false` は昇順で並べ替えます。                                                                                                          |

<div id="build-the-filter-parameter">
  ### filter パラメーターを作成する
</div>

`filter` パラメーターには JSON オブジェクトを指定します。例:

```json theme={null}
{
  "GeneralOperator": "AND",
  "FilterItems": [
    {
      "PropertyKey": "Date",
      "PropertyOperator": "BETWEEN",
      "PropertyValues": [
        "2021-08-28",
        "00:00:00",
        "2023-09-28",
        "23:59:59"
      ]
    }
  ]
}
```

`PropertyKey` パラメーターと `PropertyOperator` パラメーターの値を確認するには、管理および監視コンソールでフィルターを作成します。

<Steps>
  <Step title="ブラウザーの開発者ツールを開く">
    ブラウザーのメニューで **More tools → Developer tools** をクリックし、**Network** タブに移動します。
  </Step>

  <Step title="コンソールでフィルターを作成する">
    管理および監視コンソールを起動し、**Processing Monitor → セキュリティ イベント ログ** に移動して、<img src="https://mintcdn.com/abbyy/39LtOHLEp1q7pm1x/images/flexi-capture/Add_filter.png?fit=max&auto=format&n=39LtOHLEp1q7pm1x&q=85&s=7fca1d511f8470021946ae439989fb68" alt="フィルター追加ボタン" style={{display:"inline-block",verticalAlign:"middle",margin:0}} width="22" height="22" data-path="images/flexi-capture/Add_filter.png" /> ボタンをクリックします。
  </Step>

  <Step title="フィルター条件を適用する">
    フィルター条件を指定し、**Apply** をクリックします。
  </Step>

  <Step title="フィルターパラメーターを確認する">
    `GetFilteredSecurityEvent` リクエストをクリックします。フィルタリング パラメーターは **Payload** タブに表示されます。
  </Step>
</Steps>

<div id="example-script">
  ## スクリプト例
</div>

以下のPowerShellスクリプトは、このAPIを使用してセキュリティイベントログをダウンロードする方法を示しています。

<Note>
  このスクリプト内のパラメーターを、ご使用のサーバーアドレス、テナント名、およびお客様の認証情報に置き換えてください。
</Note>

```powershell theme={null}
# パラメーター
$server = "https://<server address>"
$tenant = "<tenant name>"
$user = "<user name>"
$password = "<password>"
#ログの保存先フォルダーのパス
$folder = "C:\Temp\Logs\Stage"
$reportFileName = "Project_SecurityEvents-{0:yyMMdd-HHmmss}.csv" -f (Get-Date)
# ログパラメーター
$requestBody = @"
filter={
    "Name": "Filter By Date",
    "GeneralOperator": "AND",
    "FilterItems": [
        {
            "PropertyKey": "Date",
            "PropertyOperator": "BETWEEN",
            "PropertyValues": [
                "2021-08-28",
                "00:00:00",
                "2023-09-28",
                "23:59:59"
            ]
        }
    ]
}
&columnsOrder=Id,Date,EventType,Details,RemoteHost,Principal,TenantName,Writer,WriterTenantName,
&sortColumnindex=1
&sortOrder=true
"@
#------------------------------------------------------------------------------
$methodUri = "/Project/GetSecurityEventsCSV"
$authServer = $server
$ServerSitePath = "/FlexiCapture12/Monitoring"

function Write-Line($str, $color = "White")
{
    Write-Host $str -ForegroundColor $color
}

function Join-Uri
{
    param([Parameter(Mandatory, ValueFromPipeline)] [string]$parent, [string]$child)
    if ($parent -eq "") {return $child;}
    if ($child -eq ""){return $parent}
    if ($parent.endswith("/") -or $parent.endswith("\\")) {$parent = $parent.substring(0,$parent.Length-1)}
    if ($child.startswith("/") -or $child.startswith("\\")) {$child = $child.substring(1,$child.Length-1)}
    return "$parent/$child"
}

function Get-AuthTicket($server, $user, $password, $tenant)
{
    $tenantSuffix=""
    if ($tenant -ne ''){ $tenantSuffix = "?tenant=$tenant"}
    $URL = Join-Uri $authServer "/FlexiCapture12/Server/FCAuth/API/Soap$tenantSuffix"
    $SOAPRequest = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><FindUser xmlns="urn:http://www.abbyy.com/FlexiCapture"><userLogin>user</userLogin></FindUser></soap:Body></soap:Envelope>'
    $Headers = @{
        'SOAPAction' = '"#FindUser"'
        'Content-Type' = 'text/xml; charset=utf-8'
        'Authorization' = "Basic $([System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("$($user):$($password)")))"
    }
    try
    {
        $response1 = Invoke-WebRequest -Uri $URL -Headers $Headers -Body $SOAPRequest -Method 'POST'
        return $response1.Headers['AuthTicket']
    }
    catch{
        Write-Line -str "Couldn't get 'AuthTicket': $_" -color "Red"
        return ""
    }
}

function Download-CSVReport($server, $tenant, $authTicket, $methodUri, $requestBody, $folder, $reportFileName)
{
    $reportFullFilePath = Join-Path $folder $reportFileName
    #フォルダーをサイレント作成（存在しない場合）
    New-Item -ItemType Directory -Force -Path $folder | Out-Null
    if ($authTicket -eq "" -or $authTicket -eq $null)
    {
        Write-Line -str "Couldn't get 'CSV-Report'" -color "Red"
    }
    else
    {
        $header = @{ "Accept" = "*/*"}
        $session = [Microsoft.PowerShell.Commands.WebRequestSession]::new()
        $session.Cookies.Add($server, [System.NET.Cookie]::new("FlexiCaptureTmpPrn$tenant", "Ticket=$authTicket"))
        $tenantInUrl=""
        if ($tenant -ne '') { $tenantInUrl = "/$tenant"}
        $uri = Join-Uri $server $ServerSitePath | Join-Uri -child $tenantInUrl | Join-Uri -child $methodUri
        try{
            $response = Invoke-WebRequest -Uri $uri -Method 'POST' -Headers $header -WebSession $session -Body $requestBody -OutFile $reportFullFilePath -MaximumRedirection 0 -ErrorAction Ignore -PassThru
            if ($response.StatusCode -lt 300)
            {
                Write-Line "CSV-Report done: $reportFullFilePath" "Green"
            }
            else
            {
                Write-Line -str "HttpStatus $($response.StatusCode) in getting CSV-Report." -color "Red"
            }
        }
        catch{
            Write-Line -str "Couldn't get CSV-Report: $_" -color "Red"
            return ""
        }
    }
}

$authTicket = Get-AuthTicket -server $server -user $user -password $password -tenant $tenant
Download-CSVReport -server $server -tenant $tenant -authTicket $authTicket -methodUri $methodUri -requestBody $requestBody -folder $folder -reportFileName $reportFileName
```
