次の方法で共有


失敗による拒否 <denyByFailure>

概要

<denyByFailure> 要素は、FTP クライアントが一定期間内に認証に失敗した回数に基づいて、FTP サービスへのアクセスを拒否するように FTP サービスを構成します。 ログイン試行の失敗回数がその回数に達すると、FTP 接続は強制的に閉じられ、クライアント IP アドレスは一定期間 (entryExpiration 属性で設定された) の間、FTP サービスへのアクセスをブロックされます。 失敗率によるアクセスの拒否は、個々のサイトではなく、サーバーに対してのみ有効にすることができます。

Note

クライアントの IP アドレスが、サーバー レベルで指定された [FTP IP アドレスとドメインの制限] 機能の特定の IP アドレスの許可エントリと一致する場合、クライアントは追加の信頼で扱われ、FTP ログオン試行の制限チェックをバイパスできます。

互換性

バージョン メモ
IIS 10.0 <denyByFailure> 要素は、IIS 10.0 では変更されませんでした。
IIS 8.5 <denyByFailure> 要素は、IIS 8.5 では変更されませんでした。
IIS 8.0 <denyByFailure> 要素は IIS 8.0 で導入されました。
IIS 7.5 該当なし
IIS 7.0 該当なし
IIS 6.0 該当なし

段取り

FTP サーバーでの認証によるアクセスの拒否をサポートするには、FTP サービス役割サービスをインストールする必要があります。

Windows Server 2012

  1. Windows キーを押してから、[サーバー マネージャー] をクリックします。

  2. サーバー マネージャーで、[管理] をクリックし、[役割と機能の追加] をクリックします。

  3. 役割と機能の追加ウィザードで次のように操作します。

    • [開始する前に] ページで [次へ] をクリックします。
    • [インストールの種類] ページでインストールの種類を選んでから、[次へ] をクリックします。
    • [サーバーの選択] ページで適切なサーバーを選んでから、[次へ] をクリックします。
    • [サーバーの役割] ページで、[Web サーバー (IIS)] がオンになっていることを確認してから、展開します。
    • [FTP サーバー] を展開し、[FTP Service][FTP 拡張] の両方をオンにしてから、[次へ] をクリックします。
    • [機能] ページで [次へ] をクリックします。
    • [インストール オプションの確認] ページで、[インストール] をクリックします。
    • [結果] ページで、 [閉じる]をクリックします。

Windows 8

  1. Windows のコントロール パネルを開きます。
  2. Windows コントロール パネルで、[プログラムと機能] を開きます。
  3. [Programs and Features]\(プログラムと機能\) で、[Turn Windows features on or off]\(Windows 機能を有効または無効にする\) をクリックします。
  4. [Windows の機能] ダイアログ ボックスで、[インターネット インフォメーション サービス] を展開してから、[FTP サーバー] を展開します。
  5. [FTP サーバー][FTP Service][FTP 拡張] をオンにしてから、[OK] をクリックします。

操作方法

ログオン失敗率に基づいて FTP サーバーへのアクセスを拒否する方法

  1. インターネット インフォメーション サービス (IIS) マネージャーを開きます。

    • Windows Server 2012 以降を使用している場合:

      • タスク バーで、[サーバー マネージャー][ツール][インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
    • Windows 8 以降を使用している場合:

      • Windows キーを押しながら文字 X を押し、次に [コントロール パネル] をクリックします。
      • [管理ツール] をクリックし、次に [インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
  2. [接続] ペインでサーバーを選びます。

  3. [ホーム] ペインで、[FTP Logon Attempt Restrictions] 機能をダブルクリックします。

    [Enable F T P Logon Attempt Restrictions]\(F T P ログオン試行の制限を有効にする\)、[ログイン試行の失敗の最大数]、[期間 (秒単位)] フィールドのスクリーンショット。

  4. [FTP Logon Attempt Restrictions] ダイアログ ボックスで、[有効にする] をクリックして制限を有効にしてから、失敗の最大数と、それらの失敗によって FTP サービスへのアクセスが拒否されるプロンプトが表示されるまでの期間を入力します。

  5. [ログのみに書き込む] をクリックすると、条件が満たされたことがログされますが、ログオン試行はブロックされません。

  6. [操作] ペインで [適用] をクリックします。

構成

<denyByFailure> 要素はサーバー レベルで構成されます。

属性

属性 説明
enabled 省略可能な Boolean 属性です。

FTP サービスが失敗率に基づいてアクセスを拒否できるようにします。

既定値は False です。
maxFailure 省略可能な uint 属性。

FTP サービスへのアクセスが拒否されるプロンプトが表示される失敗の数を入力します。

既定値は 4 です。
entryExpiration 省略可能な TimeSpan 属性。

指定した回数の失敗により FTP サービスへのアクセスが拒否されるプロンプトが表示されるまでの期間を入力します。

既定値は 00:00:30 です。
loggingOnlyMode 省略可能な Boolean 属性です。

失敗率が原因ではアクセスは拒否されず、イベントがログされるように指定します。

既定値は False です。

子要素

なし。

構成サンプル

次のサンプルでは、<denyByFailure> 要素を構成します。

<system.ftpServer>
   <security>
      <authentication>
         <denyByFailure enabled="true" maxFailure="5" entryExpiration="00:00:45" loggingOnlyMode="false" />
      </authentication>
   </security>
</system.ftpServer>

サンプル コード

次のコード サンプルでは、ログオン失敗率に基づいて FTP サーバーへのアクセスを拒否するように構成します。

AppCmd.exe

appcmd.exe set config  -section:system.ftpServer/security/authentication /denyByFailure.enabled:"True" /denyByFailure.maxFailure:"10" /denyByFailure.entryExpiration:"00:00:35" /denyByFailure.loggingOnlyMode:"False"  /commit:apphost

Note

AppCmd.exe を使用してこれらの設定を構成する場合は、commit パラメーターを必ず apphost に設定する必要があります。 これにより、ApplicationHost.config ファイルの適切な ___location セクションに構成設定がコミットされます。

C#

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample {

    private static void Main() {
        
        using(ServerManager serverManager = new ServerManager()) { 
            Configuration config = serverManager.GetApplicationHostConfiguration();
            
            ConfigurationSection authenticationSection = config.GetSection("system.ftpServer/security/authentication");
            
            ConfigurationElement denyByFailureElement = authenticationSection.GetChildElement("denyByFailure");
            denyByFailureElement["enabled"] = true;
            denyByFailureElement["maxFailure"] = 10;
            denyByFailureElement["entryExpiration"] = TimeSpan.Parse("00:00:35");
            denyByFailureElement["loggingOnlyMode"] = false;
            
            serverManager.CommitChanges();
        }
    }
}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration
Module Sample

   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetApplicationHostConfiguration
      Dim authenticationSection As ConfigurationSection = config.GetSection ("system.ftpServer/security/authentication")
      Dim denyByFailureElement As ConfigurationElement = authenticationSection.GetChildElement("denyByFailure")
      denyByFailureElement("enabled") = true
      denyByFailureElement("maxFailure") = 10
      denyByFailureElement("entryExpiration") = TimeSpan.Parse("00:00:35")
      denyByFailureElement("loggingOnlyMode") = false
      serverManager.CommitChanges
   End Sub
End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";

var authenticationSection = adminManager.GetAdminSection("system.ftpServer/security/authentication", "MACHINE/WEBROOT/APPHOST");
var denyByFailureElement = authenticationSection.ChildElements.Item("denyByFailure");
denyByFailureElement.Properties.Item("enabled").Value = true;
denyByFailureElement.Properties.Item("maxFailure").Value = 10;
denyByFailureElement.Properties.Item("entryExpiration").Value = "00:00:35";
denyByFailureElement.Properties.Item("loggingOnlyMode").Value = false;

adminManager.CommitChanges();

VBScript

Set adminManager = CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"

Set authenticationSection = adminManager.GetAdminSection("system.ftpServer/security/authentication", "MACHINE/WEBROOT/APPHOST")
Set denyByFailureElement = authenticationSection.ChildElements.Item("denyByFailure")
denyByFailureElement.Properties.Item("enabled").Value = true
denyByFailureElement.Properties.Item("maxFailure").Value = 10
denyByFailureElement.Properties.Item("entryExpiration").Value = "00:00:35"
denyByFailureElement.Properties.Item("loggingOnlyMode").Value = false

adminManager.CommitChanges()

PowerShell

Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.ftpServer/security/authentication/denyByFailure" -name "enabled" -value "True"
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.ftpServer/security/authentication/denyByFailure" -name "maxFailure" -value 10
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.ftpServer/security/authentication/denyByFailure" -name "entryExpiration" -value "00:00:35"
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.ftpServer/security/authentication/denyByFailure" -name "loggingOnlyMode" -value "False"