次の方法で共有


既定の FTP ユーザー分離設定 <userIsolation>

概要

<userIsolation> 要素は、FTP サイトの特定のセクションで FTP クライアントを開始または制限するために使われます。 サーバー管理者は、<userIsolation> 要素に指定したオプションに応じて、1 つの FTP サイトが複数のユーザー アカウントで共有される共有サーバー環境でユーザー間の不正アクセスを防ぐことができます。

FTP ユーザー分離は IIS 6.0 で導入されましたが、FTP 7.0 と FTP 7.5 で大幅に更新されました。 以前のすべての FTP ユーザー分離機能は下位互換性のために引き続き使用できますが、ユーザー分離モードでは次のオプションを使用できるようになりました。

モード 説明
なし FTP 7.0 と FTP 7.5 でこのモードを指定すると、FTP サイトのルートで常に FTP クライアントを起動するようにユーザー分離が構成されます (これは IIS 6.0 では不可能でした)。注: どの FTP ユーザーでも、十分なアクセス許可があれば、その FTP サイト内の他の FTP ユーザーのコンテンツにアクセスできる可能性があります。
StartInUsersDirectory IIS 6.0 では、ユーザー アカウントと同じ名前のディレクトリが存在し、ユーザー分離が無効になっている場合、FTP クライアントはそのユーザー名のディレクトリで起動します。 モードに StartInUsersDirectory を指定すると、FTP 7.0 と FTP 7.5 でも引き続きこのようにすることができます。 注: どの FTP ユーザーでも、十分なアクセス許可があれば、その FTP サイト内の他の FTP ユーザーのコンテンツにアクセスできる可能性があります。
IsolateRootDirectoryOnly IIS 6.0 では、ユーザー分離を有効にし、ユーザーが初めてサーバーにログオンしたときの起動場所となる物理ディレクトリを作成した場合、グローバル仮想ディレクトリを使用できました。 多数の FTP ユーザー間でコンテンツを共有する場合は、グローバル仮想ディレクトリを作成できました。 モードに IsolateRootDirectoryOnly を指定すると、FTP 7.0 と FTP 7.5 でも引き続きこのオプションを使用できます。
IsolateAllDirectories FTP 7.0 と FTP 7.5 でこのモードを指定すると、FTP クライアントは、最初にサーバーにログオンしたときに、ユーザー アカウントの名前と一致するディレクトリで起動します。 このモードを使うと、これらのアカウントごとに仮想ディレクトリを使用できます。物理ディレクトリを作成する必要がなくなりました (これは IIS 6.0 では不可能でした)。ただし、このオプションを使う場合は、グローバル仮想ディレクトリを使用できなくなります。 複数の FTP ユーザー間でフォルダーを共有するには、ユーザーごとにグローバル パスに対する仮想ディレクトリを作成する必要があります。
ActiveDirectory FTP 7.0 と FTP 7.5 でこのモードを指定すると、FTP サービスは Active Directory 設定内の各ユーザーのアカウントからユーザー分離設定を取得します。このモードは IIS 6.0 と同じように機能します。
Custom FTP 7.5 では、ユーザー分離モードに [カスタム] を指定できるようになりました。 このモードでは、カスタム FTP プロバイダーを作成することにより、FTP 拡張機能を使ってカスタム ユーザー分離を実現できます。

ユーザー分離に IsolateRootDirectoryOnly または IsolateAllDirectories モードを使う場合、物理または仮想ディレクトリ パスは次の階層を使う必要があります。

ユーザー アカウントの種類 ホーム ディレクトリの構文
匿名ユーザー %FtpRoot%\LocalUser\Public
ローカル Windows ユーザー アカウント (基本認証が必要) %FtpRoot%\LocalUser\%UserName%
Windows ドメイン アカウント (基本認証が必要) %FtpRoot%\%UserDomain%\%UserName%
IIS マネージャーまたは ASP.NET のカスタム認証ユーザー アカウント %FtpRoot%\LocalUser\%UserName%

互換性

バージョン メモ
IIS 10.0 <userIsolation> 要素は、IIS 10.0 では変更されませんでした。
IIS 8.5 <userIsolation> 要素は、IIS 8.5 では変更されませんでした。
IIS 8.0 <userIsolation> 要素は IIS 8.0 では変更されませんでした。
IIS 7.5 <ftpServer> 要素の <userIsolation> 要素は、IIS 7.5 の機能として付属しています。
IIS 7.0 <ftpServer> 要素の <userIsolation> 要素が、IIS 7.0 用の別個のダウンロードとして FTP 7.0 で導入されました。
IIS 6.0 該当なし

Note

FTP 7.0 サービスと FTP 7.5 サービスは IIS 7.0 とは別に出荷され、次の URL からモジュールをダウンロードしてインストールする必要がありました。

https://www.iis.net/expand/FTP

Windows 7 と Windows Server 2008 R2 では、FTP 7.5 サービスは IIS 7.5 の機能として付属しているため、FTP サービスのダウンロードは必要なくなりました。

段取り

Web サーバーの FTP 公開をサポートするには、FTP サービスをインストールする必要があります。 そのためには、次のステップに従います。

Windows Server 2012 または Windows Server 2012 R2

  1. タスク バーで [サーバー マネージャー]をクリックします。

  2. [サーバー マネージャー] で、[管理] メニューを選択し、[役割と機能の追加] を選択します。

  3. [役割と機能の追加] ウィザードで、[次へ] をクリックします。 インストールの種類を選択し、[次へ] をクリックします。 対象サーバーを選択し、[次へ] をクリックします。

  4. [サーバーの役割] ページで、[Web サーバー (IIS)] を展開して、[FTP サーバー] を選びます。

    Note

    FTP サービスに対して ASP.NET メンバーシップ認証または IIS マネージャー認証をサポートするには、[FTP Service] に加えて[FTP 拡張] も選択する必要があります。
    Windows Server 2012 または 2012 R2 の役割の一覧のスクリーンショット。 .

  5. [次へ] をクリックし、[機能の選択] ページで再度 [次へ] をクリックします。

  6. [インストール オプションの確認] ページで、[インストール] をクリックします。

  7. [結果] ページで、 [閉じる]をクリックします。

Windows 8 または Windows 8.1

  1. [スタート] 画面で、ポインターを左下隅まで移動し、[スタート] ボタンを右クリックし、[コントロール パネル] をクリックします。

  2. [コントロール パネル][プログラムと機能] をクリックし、[Windows の機能の有効化または無効化] をクリックします。

  3. [インターネット インフォメーション サービス] を展開し、[FTP サーバー] を展開します。

    Note

    FTP サービスに対して ASP.NET メンバーシップ認証または IIS マネージャー認証をサポートするには、[FTP 拡張] も選択する必要があります。
    Windows 8 または 8.1 の [Windows 機能] ダイアログのスクリーンショット。

  4. OK をクリックします。

  5. 閉じるをクリックします。

Windows Server 2008 R2

  1. タスク バーで [スタート] をクリックし、[管理ツール] をポイントして、[サーバー マネージャ] をクリックします。

  2. [サーバー マネージャ] 階層ウィンドウで [役割] を展開し、[Web サーバー (IIS)] をクリックします。

  3. [Web サーバー (IIS)] ウィンドウで、[役割サービス] セクションまでスクロールし、[役割サービスの追加] をクリックします。

  4. [役割サービスの追加] ウィザード[役割サービスの選択] ページで [FTP サーバー] を展開します。

  5. [FTP Service] を選択します。

    Note

    FTP サービスに対して ASP.NET メンバーシップ認証または IIS マネージャー認証をサポートするには、[FTP 拡張] も選択する必要があります。
    Windows Server 2008 R2 の [役割サービスの追加] ウィンドウのスクリーンショット。

  6. 次へ をクリックします。

  7. [インストール オプションの確認] ページで、[インストール] をクリックします。

  8. [結果] ページで、 [閉じる]をクリックします。

Windows 7

  1. タスク バーで、[スタート][コントロール パネル] の順にクリックします。

  2. [コントロール パネル][プログラムと機能] をクリックし、[Windows の機能の有効化または無効化] をクリックします。

  3. [インターネット インフォメーション サービス][FTP サーバー] の順に展開します。

  4. [FTP Service] を選択します。

    Note

    FTP サービスに対して ASP.NET メンバーシップ認証または IIS マネージャー認証をサポートするには、[FTP 拡張] も選択する必要があります。
    [Windows 7 の機能] ダイアログ ボックスのスクリーンショット。

  5. OK をクリックします。

Windows Server 2008 または Windows Vista

  1. 次の URL からインストール パッケージをダウンロードします。

  2. 次のチュートリアルの手順に従って、FTP サービスをインストールします。

操作方法

仮想ディレクトリ内のユーザーを分離する方法

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

    • Windows Server 2012 または Windows Server 2012 R2 を使用している場合:

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

      • Windows キーを押しながら文字 X を押し、[コントロール パネル] をクリックします。
      • [管理ツール] をクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
    • Windows Server 2008 または Windows Server 2008 R2 を使用している場合:

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

      • タスク バーで、[スタート][コントロール パネル] の順にクリックします。
      • [管理ツール] をダブルクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
  2. [接続] ペインでサーバー名を展開し、[サイト] ノードを展開してから、サイトの名前をクリックします。

  3. サイトの [ホーム] ペインで、[FTP ユーザーの分離] をダブルクリックします。
    Web サイトのホームを示す [I I S マネージャー] ウィンドウのスクリーンショット。[F T P ユーザー分離] アイコンが選択されています。

  4. [FTP ユーザーの分離] ページの [ユーザーを分離する。ユーザーを次のディレクトリに制限します] で、[ユーザー名ディレクトリ (グローバル仮想ディレクトリを無効にする)] を選びます。
    [I I S Manager] ウィンドウのスクリーンショット。[F T P User Isolation]\(ユーザー分離\) ウィンドウが表示されています。

  5. [操作] ウィンドウで、[適用] をクリックします。


Active Directory を使用してユーザーを分離する方法

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

    • Windows Server 2012 または Windows Server 2012 R2 を使用している場合:

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

      • Windows キーを押しながら文字 X を押し、[コントロール パネル] をクリックします。
      • [管理ツール] をクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
    • Windows Server 2008 または Windows Server 2008 R2 を使用している場合:

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

      • タスク バーで、[スタート][コントロール パネル] の順にクリックします。
      • [管理ツール] をダブルクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
  2. [接続] ウィンドウでサーバー名を展開し、[サイト] ノードを展開してから、サイトの名前をクリックします。

  3. サイトの [ホーム] ウィンドウで、[FTP ユーザーの分離] をダブルクリックします。
    メイン ウィンドウに Web サイトの [ホーム] が表示されている [I I S マネージャー] ウィンドウのスクリーンショット。F T P ユーザー分離アイコンが選択されています。

  4. [FTP ユーザーの分離] ページの [ユーザーを分離する。ユーザーを次のディレクトリに制限します] の下の [Active Directory で構成された FTP ホーム ディレクトリ] を選び、[設定] をクリックします。
    メイン ウィンドウに F T P ユーザー分離が表示されている [I I S Manager] ウィンドウのスクリーンショット。

  5. [資格情報の設定] ダイアログ ボックスで、[ユーザー名] ボックスと [パスワード] ボックスにユーザー名とパスワードを入力します。 [パスワードの確認] ボックスにもう一度パスワードを入力し、[OK] をクリックします。

  6. [操作] ウィンドウで、[適用] をクリックします。

Active Directory をセットアップする方法の詳細については、FTP ユーザーの分離を使用した複数の FTP サイトのホスト (IIS 6.0) に関するトピックの「Active Directory モードを使用してユーザーを分離する」セクションを参照してください。

構成

属性

属性 説明
mode 省略可能な列挙型属性。

ユーザー分離モードを指定します。
名前 説明
StartInUsersDirectory ユーザー分離を使わずに、ユーザーのディレクトリが存在する場合はそこでセッションを開始するように指定します。

数値は 0 です。
IsolateRootDirectoryOnly

ユーザー分離でルート ディレクトリのみを分離するように指定します。 ユーザーのホーム ディレクトリは物理ディレクトリである必要があります。また、グローバル仮想ディレクトリも引き続き使用できます。

数値は 1 です。

ActiveDirectory Active Directory 設定に基づいてユーザーを分離します。

数値は 2 です。
IsolateAllDirectories

ユーザー分離ですべてのディレクトリを分離するように指定します。 ユーザーのホーム ディレクトリは物理ディレクトリまたは仮想ディレクトリのいずれかを指定できますが、グローバル仮想ディレクトリは無視されます。すべての仮想ディレクトリは、各ユーザーのホーム パスの下に明示的に作成する必要があります。

数値は 3 です。

None ユーザー分離を使わないことを指定します。

数値は 4 です。
Custom カスタム FTP プロバイダーでユーザー分離を実装することを指定します。

数値は 5 です。
既定値は None です。

子要素

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

Active Directory サーバーと通信する際の接続の資格情報とタイムアウトを指定します。

構成サンプル

次のサンプルは、FTP サイトの <userIsolation> 要素を示しています。これは、そのサイトのユーザーの分離に Active Directory を使用するように FTP サービスを構成し、Active Directory サーバーへの接続用の資格情報を構成します。

<site name="ftp.example.com" id="5">
  <application path="/">
    <virtualDirectory path="/" physicalPath="c:\inetpub\www.example.com" />
  </application>
  <bindings>
    <binding protocol="ftp" bindingInformation="*:21:" />
  </bindings>
  <ftpServer>
    <userIsolation mode="ActiveDirectory">
      <activeDirectory adUserName="MyUser"
        adPassword="[enc:RsaProtectedConfigurationProvider:57686f6120447564652c2049495320526f636b73:enc]"
        adCacheRefresh="00:02:00" />
    </userIsolation>
    <security>
      <authentication>
        <basicAuthentication enabled="true" />
        <anonymousAuthentication enabled="false" />
      </authentication>
    </security>
  </ftpServer>
</site>

サンプル コード

次の例は、FTP サイトに対する Active Directory ユーザーの分離を構成します。

AppCmd.exe

appcmd.exe set config  -section:system.applicationHost/sites /[name='ftp.example.com'].ftpServer.userIsolation.mode:"ActiveDirectory" /commit:apphost
appcmd.exe set config  -section:system.applicationHost/sites /[name='ftp.example.com'].ftpServer.userIsolation.activeDirectory.adUserName:"MyUser" /[name='ftp.example.com'].ftpServer.userIsolation.activeDirectory.adPassword:"MyPassword" /[name='ftp.example.com'].ftpServer.userIsolation.activeDirectory.adCacheRefresh:"00:02:00" /commit:apphost

Note

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

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 sitesSection = config.GetSection("system.applicationHost/sites");
            
            ConfigurationElementCollection sitesCollection = sitesSection.GetCollection();
            
            ConfigurationElement siteElement = FindElement(sitesCollection, "site", "name", @"ftp.example.com");
            if (siteElement == null) throw new InvalidOperationException("Element not found!");

            ConfigurationElement ftpServerElement = siteElement.GetChildElement("ftpServer");
            
            ConfigurationElement userIsolationElement = ftpServerElement.GetChildElement("userIsolation");
            userIsolationElement["mode"] = @"ActiveDirectory";
            
            ConfigurationElement activeDirectoryElement = userIsolationElement.GetChildElement("activeDirectory");
            activeDirectoryElement["adUserName"] = @"MyUser";
            activeDirectoryElement["adPassword"] = @"MyPassword";
            activeDirectoryElement["adCacheRefresh"] = TimeSpan.Parse("00:02:00");
            
            serverManager.CommitChanges();
        }
    }
    
       private static ConfigurationElement FindElement(ConfigurationElementCollection collection, string elementTagName, params string[] keyValues)
   {
      foreach (ConfigurationElement element in collection)
      {
         if (String.Equals(element.ElementTagName, elementTagName, StringComparison.OrdinalIgnoreCase))
         {
            bool matches = true;
            for (int i = 0; i < keyValues.Length; i += 2)
            {
               object o = element.GetAttributeValue(keyValues[i]);
               string value = null;
               if (o != null)
               {
                  value = o.ToString();
               }
               if (!String.Equals(value, keyValues[i + 1], StringComparison.OrdinalIgnoreCase))
               {
                  matches = false;
                  break;
               }
            }
            if (matches)
            {
               return element;
            }
         }
      }
      return null;
   }
}

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 sitesSection As ConfigurationSection = config.GetSection("system.applicationHost/sites")
      Dim sitesCollection As ConfigurationElementCollection = sitesSection.GetCollection

      Dim siteElement As ConfigurationElement = FindElement(sitesCollection, "site", "name", "ftp.example.com")
      If (siteElement Is Nothing) Then
         Throw New InvalidOperationException("Element not found!")
      End If

      Dim ftpServerElement As ConfigurationElement = siteElement.GetChildElement("ftpServer")

      Dim userIsolationElement As ConfigurationElement = ftpServerElement.GetChildElement("userIsolation")
      userIsolationElement("mode") = "ActiveDirectory"

      Dim activeDirectoryElement As ConfigurationElement = userIsolationElement.GetChildElement("activeDirectory")
      activeDirectoryElement("adUserName") = "MyUser"
      activeDirectoryElement("adPassword") = "MyPassword"
      activeDirectoryElement("adCacheRefresh") = TimeSpan.Parse("00:02:00")

      serverManager.CommitChanges()
   End Sub

   Private Function FindElement(ByVal collection As ConfigurationElementCollection, ByVal elementTagName As String, ByVal ParamArray keyValues() As String) As ConfigurationElement
      For Each element As ConfigurationElement In collection
         If String.Equals(element.ElementTagName, elementTagName, StringComparison.OrdinalIgnoreCase) Then
            Dim matches As Boolean = True
            Dim i As Integer
            For i = 0 To keyValues.Length - 1 Step 2
               Dim o As Object = element.GetAttributeValue(keyValues(i))
               Dim value As String = Nothing
               If (Not (o) Is Nothing) Then
                  value = o.ToString
               End If
               If Not String.Equals(value, keyValues((i + 1)), StringComparison.OrdinalIgnoreCase) Then
                  matches = False
                  Exit For
               End If
            Next
            If matches Then
               Return element
            End If
         End If
      Next
      Return Nothing
   End Function


End Module

JavaScript

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

var sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST");
var sitesCollection = sitesSection.Collection;
var siteElementPos = FindElement(sitesCollection, "site", ["name", "ftp.example.com"]);
if (siteElementPos == -1) throw "Element not found!";

var siteElement = sitesCollection.Item[siteElementPos]);
var ftpServerElement = siteElement.ChildElements.Item("ftpServer");
var userIsolationElement = ftpServerElement.ChildElements.Item("userIsolation");
userIsolationElement.Properties.Item("mode").Value = "ActiveDirectory";
var activeDirectoryElement = userIsolationElement.ChildElements.Item("activeDirectory");

activeDirectoryElement.Properties.Item("adUserName").Value = "MyUser";
activeDirectoryElement.Properties.Item("adPassword").Value = "MyPassword";
activeDirectoryElement.Properties.Item("adCacheRefresh").Value = "00:02:00";
adminManager.CommitChanges();

function FindElement(collection, elementTagName, valuesToMatch) {
   for (var i = 0; i < collection.Count; i++) {
      var element = collection.Item(i);
      if (element.Name == elementTagName) {
         var matches = true;
         for (var iVal = 0; iVal < valuesToMatch.length; iVal += 2) {
            var property = element.GetPropertyByName(valuesToMatch[iVal]);
            var value = property.Value;
            if (value != null) {
               value = value.toString();
            }
            if (value != valuesToMatch[iVal + 1]) {
               matches = false;
               break;
            }
         }
         if (matches) {
            return i;
         }
      }
   }
   return -1;
}

VBScript

Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST")
Set sitesCollection = sitesSection.Collection

siteElementPos = FindElement(sitesCollection, "site", Array("name", "ftp.example.com"))
If siteElementPos = -1 Then
   WScript.Echo "Element not found!"
   WScript.Quit
End If

Set siteElement = sitesCollection.Item(siteElementPos)
Set ftpServerElement = siteElement.ChildElements.Item("ftpServer")
Set userIsolationElement = ftpServerElement.ChildElements.Item("userIsolation")
userIsolationElement.Properties.Item("mode").Value = "ActiveDirectory"
Set activeDirectoryElement = userIsolationElement.ChildElements.Item("activeDirectory")

activeDirectoryElement.Properties.Item("adUserName").Value = "MyUser"
activeDirectoryElement.Properties.Item("adPassword").Value = "MyPassword"
activeDirectoryElement.Properties.Item("adCacheRefresh").Value = "00:02:00"

adminManager.CommitChanges()

Function FindElement(collection, elementTagName, valuesToMatch)
   For i = 0 To CInt(collection.Count) - 1
      Set element = collection.Item(i)
      If element.Name = elementTagName Then
         matches = True
         For iVal = 0 To UBound(valuesToMatch) Step 2
            Set property = element.GetPropertyByName(valuesToMatch(iVal))
            value = property.Value
            If Not IsNull(value) Then
               value = CStr(value)
            End If
            If Not value = CStr(valuesToMatch(iVal + 1)) Then
               matches = False
               Exit For
            End If
         Next
         If matches Then
            Exit For
         End If
      End If
   Next
   If matches Then
      FindElement = i
   Else
      FindElement = -1
   End If
End Function