Partager via


Ajout de fonctionnalités personnalisées FTP par défaut <ajouter>

Vue d’ensemble

L’élément <add> de l’élément <providers> ajoute un fournisseur de fonctionnalités à la collection par défaut de fournisseurs personnalisés FTP pour les sites FTP.

Remarque

Les fournisseurs ajoutés à cette collection peuvent implémenter des recherches personnalisées de journalisation ou de répertoire de base ; Les fournisseurs FTP personnalisés qui implémentent les recherches d’authentification et de rôle sont ajoutés à la collection <ftpServer/security/authentication/customAuthentication>.

Remarque

Les fonctionnalités personnalisées ajoutées à l’élément <customFeatures/providers> doivent être inscrites dans la <system.ftpServer/providerDefinitions> collection.

Remarque

La prise en charge de la création de fournisseurs de fonctionnalités personnalisés a été introduite dans FTP 7.5. Pour plus d’informations sur la création de fournisseurs de fonctionnalités personnalisés FTP, consultez la rubrique Développement pour FTP 7.5 sur le site web de Microsoft IIS.net.

Compatibilité

Version Notes
IIS 10.0 L’élément <add> n’a fait l’objet d’aucune modification dans IIS 10.0.
IIS 8.5 L’élément <add> n’a fait l’objet d’aucune modification dans IIS 8.5.
IIS 8.0 L’élément <add> n’a fait l’objet d’aucune modification dans IIS 8.0.
IIS 7.5 L’élément <add> de l’élément <providers> est fourni en tant que fonctionnalité d’IIS 7.5.
IIS 7.0 L’élément <add> de l’élément <providers> a été introduit dans FTP 7.0, qui était un téléchargement distinct pour IIS 7.0.
IIS 6.0 Le service FTP dans IIS 6.0 ne prenait pas en charge l’extensibilité.

Remarque

Les services FTP 7.0 et FTP 7.5 fournis hors bande pour IIS 7.0, qui nécessitaient le téléchargement et l’installation des modules à partir de l’URL suivante :

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

Avec Windows 7 et Windows Server 2008 R2, le service FTP 7.5 est fourni en tant que fonctionnalité pour IIS 7.5. Le téléchargement du service FTP n’est donc plus nécessaire.

Programme d’installation

Pour prendre en charge la publication FTP pour votre serveur web, vous devez installer le service FTP. Pour cela, procédez comme suit.

Windows Server 2012 ou Windows Server 2012 R2

  1. Dans la barre des tâches, cliquez sur Gestionnaire de serveur.

  2. Dans Gestionnaire de serveur, cliquez sur le menu Gérer, puis sur Ajouter des rôles et des fonctionnalités.

  3. Dans l’Assistant Ajout de rôles et de fonctionnalités, cliquez sur Suivant. Sélectionnez le type d’installation, puis cliquez sur Suivant. Sélectionnez le serveur de destination, puis cliquez sur Suivant.

  4. Dans la page rôles de serveur, développez serveur web (IIS), puis sélectionnez serveur FTP.

    Remarque

    Pour prendre en charge ASP. L’authentification d’appartenance ou l’authentification du gestionnaire IIS pour le service FTP, vous devez sélectionner extensibilité FTP, en plus de service FTP.
    Screenshot of Web Server I I S and F T P Server pane expanded with F T P Extensibility highlighted. .

  5. Cliquez sur Suivant, puis, dans la page Sélectionner des fonctionnalités, cliquez à nouveau sur Suivant.

  6. Dans la page Confirmer les sélections d’installation, cliquez sur Installer.

  7. Dans la page Résultats , cliquez sur Fermer.

Windows 8 ou Windows 8.1

  1. Dans l’écran d’accueil, déplacez le pointeur jusqu’au coin inférieur gauche, cliquez avec le bouton droit sur le bouton Démarrer, puis cliquez sur Panneau de configuration.

  2. Dans le Panneau de configuration, cliquez sur Programmes et fonctionnalités, puis sur Activer ou désactiver des fonctionnalités Windows.

  3. Développez Internet Information Services, puis sélectionnez serveur FTP.

    Remarque

    Pour prendre en charge ASP. L’authentification d’appartenance ou l’authentification du Gestionnaire IIS pour le service FTP, vous devez également sélectionner extensibilité FTP.
    Image of Internet Information Services and F T P Server pane expanded with F T P Extensibility highlighted.

  4. Cliquez sur OK.

  5. Cliquez sur Fermer.

Windows Server 2008 R2

  1. Dans la barre des tâches, cliquez sur Démarrer, pointez sur Outils d’administration, puis cliquez sur Gestionnaire de serveur.

  2. Dans le volet hiérarchie du Gestionnaire de serveur, développez Rôles, puis cliquez sur Serveur web (IIS).

  3. Dans le volet Serveur web (IIS), faites défiler jusqu’à la section Services de rôle, puis cliquez sur Ajouter des services de rôle.

  4. Dans la page Sélectionner des services de rôle de l’Assistant Ajouter des services de rôle, développez le Serveur FTP.

  5. Sélectionnez Service FTP.

    Remarque

    Pour prendre en charge ASP. L’authentification d’appartenance ou l’authentification du Gestionnaire IIS pour le service FTP, vous devez également sélectionner extensibilité FTP.
    Image of Select Role Services page with F T P Server pane expanded and F T P Service selected.

  6. Sélectionnez Suivant.

  7. Dans la page Confirmer les sélections pour l'installation, cliquez sur Installer.

  8. Dans la page Résultats , cliquez sur Fermer.

Windows 7

  1. Dans la barre des tâches, cliquez sur Démarrer, puis sur Panneau de configuration.

  2. Dans le Panneau de configuration, cliquez sur Programmes et fonctionnalités, puis sur Activer ou désactiver des fonctionnalités Windows.

  3. Développez Internet Information Services, puis serveur FTP.

  4. Sélectionnez Service FTP.

    Remarque

    Pour prendre en charge ASP. L’authentification d’appartenance ou l’authentification du Gestionnaire IIS pour le service FTP, vous devez également sélectionner extensibilité FTP.
    Screenshot of Internet Information Services and F T P Server node expanded showing F T P Service and F T P Extensibility selected.

  5. Cliquez sur OK.

Windows Server 2008 ou Windows Vista

  1. Téléchargez le package d’installation à partir de l’URL suivante :

  2. Suivez les instructions de la procédure pas à pas suivante pour installer le service FTP :

Procédure

À ce stade, il n’existe aucune interface utilisateur qui vous permet d’ajouter des fonctionnalités personnalisées à un site. Consultez les sections Configuration et exemple de code de ce document pour plus d’informations sur l’ajout de fonctionnalités personnalisées à un site FTP.

Configuration

Attributs

Attribut Description
name Attribut de chaîne requis.

Nom d’un fournisseur FTP inscrit dans la collection <system.ftpServer/providerDefinitions>.

Il n'y a pas de valeur par défaut.
enabled Attribut booléen facultatif.

true si le fournisseur est activé ; sinon, false.

La valeur par défaut est true.

Éléments enfants

Aucune.

Exemple Configuration

L’exemple de configuration suivant affiche un exemple <siteDefaults> élément pour un serveur qui définit plusieurs des valeurs par défaut du site FTP.

<siteDefaults>
   <logFile logFormat="W3C" directory="%SystemDrive%\inetpub\logs\LogFiles" />
   <traceFailedRequestsLogging enabled="true" directory="%SystemDrive%\inetpub\logs\FailedReqLogFiles" />
   <ftpServer serverAutoStart="true">
      <connections controlChannelTimeout="300" />
      <security>
         <commandFiltering>
            <add command="SYST" allowed="false" />
         </commandFiltering>
         <ssl serverCertHash="57686f6120447564652c2049495320526f636b73" controlChannelPolicy="SslAllow" dataChannelPolicy="SslAllow" />
         <sslClientCertificates clientCertificatePolicy="CertIgnore" />
         <authentication>
             <anonymousAuthentication enabled="false" />
             <basicAuthentication enabled="false" />
             <clientCertAuthentication enabled="false" />
             <customAuthentication>
                <providers>
                   <add name="FtpCustomAuthenticationModule" enabled="false" />
                </providers>
             </customAuthentication>
         </authentication>
      </security>
      <messages bannerMessage="Welcome!" allowLocalDetailedErrors="true" />
      <fileHandling keepPartialUploads="false" />
      <firewallSupport externalIp4Address="169.254.10.10" />
      <userIsolation mode="None" />
      <directoryBrowse showFlags="StyleUnix, DisplayAvailableBytes" />
      <logFile period="Daily" enabled="true" />
   </ftpServer>
</siteDefaults>

Exemple de code

Les exemples de code suivants illustrent la définition de plusieurs valeurs par défaut du site FTP.

AppCmd.exe

REM Configure FTP sites to start automatically by default.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.serverAutoStart:"True" /commit:apphost

REM Configure the default control channel time-out for 300 seconds.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.connections.controlChannelTimeout:"300" /commit:apphost

REM Configure the default FTP security options.
appcmd.exe set config -section:system.applicationHost/sites /+"siteDefaults.ftpServer.security.commandFiltering.[command='SYST',allowed='False']" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.security.ssl.controlChannelPolicy:"SslAllow" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.security.ssl.dataChannelPolicy:"SslAllow" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.security.ssl.serverCertHash:"57686f6120447564652c2049495320526f636b73" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.security.authentication.anonymousAuthentication.enabled:"False" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.security.authentication.basicAuthentication.enabled:"False" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.security.authentication.clientCertAuthentication.enabled:"False" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.security.sslClientCertificates.clientCertificatePolicy:"CertIgnore" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /+"siteDefaults.ftpServer.security.authentication.customAuthentication.providers.[name='FtpCustomAuthenticationModule',enabled='False']" /commit:apphost

REM Configure a custom default banner message and local detailed error messages.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.messages.bannerMessage:"Welcome!" /siteDefaults.ftpServer.messages.allowLocalDetailedErrors:"True" /commit:apphost

REM Configure the FTP service to keep partially-uploaded files by default.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.fileHandling.keepPartialUploads:"False" /commit:apphost

REM Configure the default external IP address of a firewall.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.firewallSupport.externalIp4Address:"169.254.10.10" /commit:apphost

REM Specify no user isolation by default.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.userIsolation.mode:"None" /commit:apphost

REM Configure UNIX-style directory listings by default and display the available drive space.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.directoryBrowse.showFlags:"StyleUnix, DisplayAvailableBytes" /commit:apphost

REM Enable logging by default with daily log file rollover.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.logFile.period:"Daily" /siteDefaults.ftpServer.logFile.enabled:"True" /commit:apphost

Remarque

Vous devez veiller à définir le paramètre commit sur apphost quand vous utilisez AppCmd.exe pour configurer ces paramètres. Cela valide les paramètres de configuration dans la section d’emplacement appropriée dans le fichier 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");
         ConfigurationElement siteDefaultsElement = sitesSection.GetChildElement("siteDefaults");
         ConfigurationElement ftpServerElement = siteDefaultsElement.GetChildElement("ftpServer");

         // Configure FTP sites to start automatically by default.
         ftpServerElement["serverAutoStart"] = true;

         // Configure the default control channel time-out for 300 seconds.
         ConfigurationElement connectionsElement = ftpServerElement.GetChildElement("connections");
            connectionsElement["controlChannelTimeout"] = 300;

         // Configure the default FTP security options.
         ConfigurationElement securityElement = ftpServerElement.GetChildElement("security");
         ConfigurationElement commandFilteringElement = securityElement.GetChildElement("commandFiltering");
         ConfigurationElementCollection commandFilteringCollection = commandFilteringElement.GetCollection();
         ConfigurationElement addElement = commandFilteringCollection.CreateElement("add");
            addElement["command"] = @"SYST";
            addElement["allowed"] = false;
            commandFilteringCollection.Add(addElement);
         ConfigurationElement sslElement = securityElement.GetChildElement("ssl");
            sslElement["controlChannelPolicy"] = @"SslAllow";
            sslElement["dataChannelPolicy"] = @"SslAllow";
            sslElement["serverCertHash"] = "57686f6120447564652c2049495320526f636b73";
         ConfigurationElement authenticationElement = securityElement.GetChildElement("authentication");
         ConfigurationElement anonymousAuthenticationElement = authenticationElement.GetChildElement("anonymousAuthentication");
            anonymousAuthenticationElement["enabled"] = false;
         ConfigurationElement basicAuthenticationElement = authenticationElement.GetChildElement("basicAuthentication");
            basicAuthenticationElement["enabled"] = false;
         ConfigurationElement clientCertAuthenticationElement = authenticationElement.GetChildElement("clientCertAuthentication");
            clientCertAuthenticationElement["enabled"] = false;
         ConfigurationElement sslClientCertificatesElement = securityElement.GetChildElement("sslClientCertificates");
            sslClientCertificatesElement["clientCertificatePolicy"] = @"CertIgnore";
         ConfigurationElement customAuthenticationElement = authenticationElement.GetChildElement("customAuthentication");
         ConfigurationElementCollection providersCollection = customAuthenticationElement.GetCollection("providers");
         ConfigurationElement addElement1 = providersCollection.CreateElement("add");
            addElement1["name"] = @"FtpCustomAuthenticationModule";
            addElement1["enabled"] = false;
            providersCollection.Add(addElement1);

         // Configure a custom default banner message and local detailed error messages.
         ConfigurationElement messagesElement = ftpServerElement.GetChildElement("messages");
            messagesElement["bannerMessage"] = @"Welcome!";
            messagesElement["allowLocalDetailedErrors"] = true;

         // Configure the FTP service to keep partially-uploaded files by default.
         ConfigurationElement fileHandlingElement = ftpServerElement.GetChildElement("fileHandling");
           fileHandlingElement["keepPartialUploads"] = false;

         // Configure the default external IP address of a firewall.
         ConfigurationElement firewallSupportElement = ftpServerElement.GetChildElement("firewallSupport");
            firewallSupportElement["externalIp4Address"] = @"169.254.10.10";

         // Specify no user isolation by default.
         ConfigurationElement userIsolationElement = ftpServerElement.GetChildElement("userIsolation");
            userIsolationElement["mode"] = @"None";

         // Configure UNIX-style directory listings by default and display the available drive space.
         ConfigurationElement directoryBrowseElement = ftpServerElement.GetChildElement("directoryBrowse");
            directoryBrowseElement["showFlags"] = @"StyleUnix, DisplayAvailableBytes";

         // Enable logging by default with daily log file rollover.
         ConfigurationElement logFileElement = ftpServerElement.GetChildElement("logFile");
            logFileElement["period"] = @"Daily";
            logFileElement["enabled"] = true;

         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 sitesSection As ConfigurationSection = config.GetSection("system.applicationHost/sites")
      Dim siteDefaultsElement As ConfigurationElement = sitesSection.GetChildElement("siteDefaults")
      Dim ftpServerElement As ConfigurationElement = siteDefaultsElement.GetChildElement("ftpServer")

      ' Configure FTP sites to start automatically by default.
      ftpServerElement("serverAutoStart") = True

      ' Configure the default control channel time-out for 300 seconds.
      Dim connectionsElement As ConfigurationElement = ftpServerElement.GetChildElement("connections")
         connectionsElement("controlChannelTimeout") = 300

      ' Configure the default FTP security options.
      Dim securityElement As ConfigurationElement = ftpServerElement.GetChildElement("security")
      Dim commandFilteringElement As ConfigurationElement = securityElement.GetChildElement("commandFiltering")
      Dim commandFilteringCollection As ConfigurationElementCollection = commandFilteringElement.GetCollection
      Dim addElement As ConfigurationElement = commandFilteringCollection.CreateElement("add")
         addElement("command") = "SYST"
         addElement("allowed") = False
         commandFilteringCollection.Add(addElement)
      Dim sslElement As ConfigurationElement = securityElement.GetChildElement("ssl")
         sslElement("controlChannelPolicy") = "SslAllow"
         sslElement("dataChannelPolicy") = "SslAllow"
         sslElement("serverCertHash") = "57686f6120447564652c2049495320526f636b73"
      Dim authenticationElement As ConfigurationElement = securityElement.GetChildElement("authentication")
      Dim anonymousAuthenticationElement As ConfigurationElement = authenticationElement.GetChildElement("anonymousAuthentication")
         anonymousAuthenticationElement("enabled") = False
      Dim basicAuthenticationElement As ConfigurationElement = authenticationElement.GetChildElement("basicAuthentication")
         basicAuthenticationElement("enabled") = False
      Dim clientCertAuthenticationElement As ConfigurationElement = authenticationElement.GetChildElement("clientCertAuthentication")
         clientCertAuthenticationElement("enabled") = False
      Dim sslClientCertificatesElement As ConfigurationElement = securityElement.GetChildElement("sslClientCertificates")
         sslClientCertificatesElement("clientCertificatePolicy") = "CertIgnore"
      Dim customAuthenticationElement As ConfigurationElement = authenticationElement.GetChildElement("customAuthentication")
      Dim providersCollection As ConfigurationElementCollection = customAuthenticationElement.GetCollection("providers")
      Dim addElement1 As ConfigurationElement = providersCollection.CreateElement("add")
         addElement1("name") = "FtpCustomAuthenticationModule"
         addElement1("enabled") = False
         providersCollection.Add(addElement1)

      ' Configure a custom default banner message and local detailed error messages.
      Dim messagesElement As ConfigurationElement = ftpServerElement.GetChildElement("messages")
         messagesElement("bannerMessage") = "Welcome!"
         messagesElement("allowLocalDetailedErrors") = True

      ' Configure the FTP service to keep partially-uploaded files by default.
      Dim fileHandlingElement As ConfigurationElement = ftpServerElement.GetChildElement("fileHandling")
         fileHandlingElement("keepPartialUploads") = False

      ' Configure the default external IP address of a firewall.
      Dim firewallSupportElement As ConfigurationElement = ftpServerElement.GetChildElement("firewallSupport")
         firewallSupportElement("externalIp4Address") = "169.254.10.10"

      ' Specify no user isolation by default.
      Dim userIsolationElement As ConfigurationElement = ftpServerElement.GetChildElement("userIsolation")
         userIsolationElement("mode") = "None"

      ' Configure UNIX-style directory listings by default and display the available drive space.
      Dim directoryBrowseElement As ConfigurationElement = ftpServerElement.GetChildElement("directoryBrowse")
         directoryBrowseElement("showFlags") = "StyleUnix, DisplayAvailableBytes"

      ' Enable logging by default with daily log file rollover.
      Dim logFileElement As ConfigurationElement = ftpServerElement.GetChildElement("logFile")
         logFileElement("period") = "Daily"
         logFileElement("enabled") = True

      serverManager.CommitChanges()
   End Sub

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 siteDefaultsElement = sitesSection.ChildElements.Item("siteDefaults");
var ftpServerElement = siteDefaultsElement.ChildElements.Item("ftpServer");

// Configure FTP sites to start automatically by default.
ftpServerElement.Properties.Item("serverAutoStart").Value = true;

// Configure the default control channel time-out for 300 seconds.
var connectionsElement = ftpServerElement.ChildElements.Item("connections");
   connectionsElement.Properties.Item("controlChannelTimeout").Value = 300;

// Configure the default FTP security options.
var securityElement = ftpServerElement.ChildElements.Item("security");
var commandFilteringElement = securityElement.ChildElements.Item("commandFiltering");
var commandFilteringCollection = commandFilteringElement.Collection;
var addElement = commandFilteringCollection.CreateNewElement("add");
   addElement.Properties.Item("command").Value = "SYST";
   addElement.Properties.Item("allowed").Value = false;
   commandFilteringCollection.AddElement(addElement);
var sslElement = securityElement.ChildElements.Item("ssl");
   sslElement.Properties.Item("controlChannelPolicy").Value = "SslAllow";
   sslElement.Properties.Item("dataChannelPolicy").Value = "SslAllow";
   sslElement.Properties.Item("serverCertHash").Value = "57686f6120447564652c2049495320526f636b73";
var authenticationElement = securityElement.ChildElements.Item("authentication");
var anonymousAuthenticationElement = authenticationElement.ChildElements.Item("anonymousAuthentication");
   anonymousAuthenticationElement.Properties.Item("enabled").Value = false;
var basicAuthenticationElement = authenticationElement.ChildElements.Item("basicAuthentication");
   basicAuthenticationElement.Properties.Item("enabled").Value = false;
var clientCertAuthenticationElement = authenticationElement.ChildElements.Item("clientCertAuthentication");
   clientCertAuthenticationElement.Properties.Item("enabled").Value = false;
var sslClientCertificatesElement = securityElement.ChildElements.Item("sslClientCertificates");
    sslClientCertificatesElement.Properties.Item("clientCertificatePolicy").Value = "CertIgnore";
var customAuthenticationElement = authenticationElement.ChildElements.Item("customAuthentication");
var providersCollection = customAuthenticationElement.ChildElements.Item("providers").Collection;
var addElement1 = providersCollection.CreateNewElement("add");
   addElement1.Properties.Item("name").Value = "FtpCustomAuthenticationModule";
   addElement1.Properties.Item("enabled").Value = false;
   providersCollection.AddElement(addElement1);

// Configure a custom default banner message and local detailed error messages.
var messagesElement = ftpServerElement.ChildElements.Item("messages");
   messagesElement.Properties.Item("bannerMessage").Value = "Welcome!";
   messagesElement.Properties.Item("allowLocalDetailedErrors").Value = true;

// Configure the FTP service to keep partially-uploaded files by default.
var fileHandlingElement = ftpServerElement.ChildElements.Item("fileHandling");
   fileHandlingElement.Properties.Item("keepPartialUploads").Value = false;

// Configure the default external IP address of a firewall.
var firewallSupportElement = ftpServerElement.ChildElements.Item("firewallSupport");
   firewallSupportElement.Properties.Item("externalIp4Address").Value = "169.254.10.10";

// Specify no user isolation by default.
var userIsolationElement = ftpServerElement.ChildElements.Item("userIsolation");
   userIsolationElement.Properties.Item("mode").Value = "None";

// Configure UNIX-style directory listings by default and display the available drive space.
var directoryBrowseElement = ftpServerElement.ChildElements.Item("directoryBrowse");
   directoryBrowseElement.Properties.Item("showFlags").Value = "StyleUnix, DisplayAvailableBytes";

// Enable logging by default with daily log file rollover.
var logFileElement = ftpServerElement.ChildElements.Item("logFile");
   logFileElement.Properties.Item("period").Value = "Daily";
   logFileElement.Properties.Item("enabled").Value = true;

adminManager.CommitChanges();

VBScript

Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST")
Set siteDefaultsElement = sitesSection.ChildElements.Item("siteDefaults")
Set ftpServerElement = siteDefaultsElement.ChildElements.Item("ftpServer")

' Configure FTP sites to start automatically by default.
ftpServerElement.Properties.Item("serverAutoStart").Value = True

' Configure the default control channel time-out for 300 seconds.
Set connectionsElement = ftpServerElement.ChildElements.Item("connections")
   connectionsElement.Properties.Item("controlChannelTimeout").Value = 300

' Configure the default FTP security options.
Set securityElement = ftpServerElement.ChildElements.Item("security")
Set commandFilteringElement = securityElement.ChildElements.Item("commandFiltering")
Set commandFilteringCollection = commandFilteringElement.Collection
Set addElement = commandFilteringCollection.CreateNewElement("add")
   addElement.Properties.Item("command").Value = "SYST"
   addElement.Properties.Item("allowed").Value = False
   commandFilteringCollection.AddElement(addElement)
Set sslElement = securityElement.ChildElements.Item("ssl")
   sslElement.Properties.Item("controlChannelPolicy").Value = "SslAllow"
   sslElement.Properties.Item("dataChannelPolicy").Value = "SslAllow"
   sslElement.Properties.Item("serverCertHash").Value = "57686f6120447564652c2049495320526f636b73"
Set authenticationElement = securityElement.ChildElements.Item("authentication")
Set anonymousAuthenticationElement = authenticationElement.ChildElements.Item("anonymousAuthentication")
   anonymousAuthenticationElement.Properties.Item("enabled").Value = False
Set basicAuthenticationElement = authenticationElement.ChildElements.Item("basicAuthentication")
   basicAuthenticationElement.Properties.Item("enabled").Value = False
Set clientCertAuthenticationElement = authenticationElement.ChildElements.Item("clientCertAuthentication")
   clientCertAuthenticationElement.Properties.Item("enabled").Value = False
Set sslClientCertificatesElement = securityElement.ChildElements.Item("sslClientCertificates")
   sslClientCertificatesElement.Properties.Item("clientCertificatePolicy").Value = "CertIgnore"
Set customAuthenticationElement = authenticationElement.ChildElements.Item("customAuthentication")
Set providersCollection = customAuthenticationElement.ChildElements.Item("providers").Collection
Set addElement1 = providersCollection.CreateNewElement("add")
   addElement1.Properties.Item("name").Value = "FtpCustomAuthenticationModule"
   addElement1.Properties.Item("enabled").Value = False
   providersCollection.AddElement(addElement1)

' Configure a custom default banner message and local detailed error messages.
Set messagesElement = ftpServerElement.ChildElements.Item("messages")
   messagesElement.Properties.Item("bannerMessage").Value = "Welcome!"
   messagesElement.Properties.Item("allowLocalDetailedErrors").Value = True

' Configure the FTP service to keep partially-uploaded files by default.
Set fileHandlingElement = ftpServerElement.ChildElements.Item("fileHandling")
   fileHandlingElement.Properties.Item("keepPartialUploads").Value = False

' Configure the default external IP address of a firewall.
Set firewallSupportElement = ftpServerElement.ChildElements.Item("firewallSupport")
   firewallSupportElement.Properties.Item("externalIp4Address").Value = "169.254.10.10"

' Specify no user isolation by default.
Set userIsolationElement = ftpServerElement.ChildElements.Item("userIsolation")
   userIsolationElement.Properties.Item("mode").Value = "None"

' Configure UNIX-style directory listings by default and display the available drive space.
Set directoryBrowseElement = ftpServerElement.ChildElements.Item("directoryBrowse")
   directoryBrowseElement.Properties.Item("showFlags").Value = "StyleUnix, DisplayAvailableBytes"

' Enable logging by default with daily log file rollover.
Set logFileElement = ftpServerElement.ChildElements.Item("logFile")
   logFileElement.Properties.Item("period").Value = "Daily"
   logFileElement.Properties.Item("enabled").Value = True

adminManager.CommitChanges()