次の方法で共有


システム FTP 認証 <authentication>

概要

<authentication> 要素を使うと、サーバー上のサイトにアクセスできるユーザー アカウントを構成できます。 認証と認可を組み合わせて使い、サーバー上のコンテンツへのアクセスをセキュリティで保護します。 認証はユーザーの ID を確認し、認可はユーザーがアクセスできるリソースとアクセスできないリソースを決定します。

IIS では、認証規則の 1 つの種類である拒否規則が定義されています。 拒否規則を使うと、サーバー上のサイトにアクセスできないユーザー アカウントまたはユーザー グループを定義できます。

互換性

バージョン メモ
IIS 10.0 <authentication> 要素は、IIS 10.0 では変更されませんでした。
IIS 8.5 <authentication> 要素は、IIS 8.5 では変更されませんでした。
IIS 8.0 <authentication> 要素は 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 Log on Attempt Restrictions]\(試行制限の有効化\) 機能が選択されている [ホーム] ウィンドウの画像。

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

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

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

構成

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

属性

なし。

子要素

要素 説明
denyByFailure 省略可能な要素です。

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

構成サンプル

次のサンプルでは、<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"