Authentification de sécurité <authentication>

Vue d’ensemble

L’authentification est le mécanisme que vous utilisez pour vérifier l’identité des visiteurs de votre site web ou de votre application web. En règle générale, vous devez affecter un nom d’utilisateur et un mot de passe à un visiteur ou autoriser un visiteur à accéder anonymement au contenu public sur votre site.

Bien que vous utilisiez l’authentification pour confirmer l’identité d’un visiteur, vous utilisez l’autorisation pour contrôler l’accès du visiteur aux différentes zones de votre site ou application.

IIS 7 prend en charge l’authentification anonyme, l’authentification de base, l’authentification par mappage de certificat client, l’authentification Digest, l’authentification par mappage de certificat client IIS et l’authentification Windows. Des modes d’authentification supplémentaires peuvent être fournis par des modules d’authentification tiers.

Après avoir installé l’un des modules d’authentification, vous devez activer le module d’authentification sélectionné pour le site web, l’application web ou le service web sur lequel vous souhaitez l’utiliser.

Toujours par défaut, IIS 7 active l’authentification en mode noyau pour le schéma d’authentification Windows (qui utilise Kerberos ou NTLM). L’authentification en mode noyau offre les avantages suivants :

  • Vos applications web peuvent s’exécuter à l’aide de comptes à privilèges inférieurs.
  • Si vous utilisez l’authentification Kerberos, vous pouvez utiliser un compte différent du compte par défaut associé au nom de principal du service (SPN) du serveur.
  • Si vous utilisez l’authentification en mode noyau, vous pouvez utiliser le fournisseur Kerberos d’authentification Windows sans effectuer de configuration SPN explicite.

Compatibilité

Version Notes
IIS 10.0 L’élément <authentication> n’a pas été modifié dans IIS 10.0.
IIS 8.5 L’élément <authentication> n’a pas été modifié dans IIS 8.5.
IIS 8.0 L’élément <authentication> n’a pas été modifié dans IIS 8.0.
IIS 7.5 L’élément <authentication> n’a pas été modifié dans IIS 7.5.
IIS 7.0 L’élément <authentication> a été introduit dans IIS 7.0.
IIS 6.0 S/O

Programme d’installation

L’élément <authentication> est inclus dans l’installation par défaut d’IIS 7.

Procédure

Comment désactiver l’authentification anonyme

  1. Ouvrez le Gestionnaire Internet Information Services (IIS) :

    • Si vous utilisez Windows Server 2012 ou Windows Server 2012 R2 :

      • Dans la barre des tâches, cliquez sur Gestionnaire de serveur, sur Outils, puis sur Gestionnaire Internet Information Services (IIS).
    • Si vous utilisez Windows 8 ou Windows 8.1 :

      • Maintenez la touche Windows enfoncée, appuyez sur la lettre X, puis cliquez sur Panneau de configuration.
      • Cliquez sur Outils d’administration, puis double-cliquez sur Gestionnaire Internet Information Services (IIS).
    • Si vous utilisez Windows Server 2008 ou Windows Server 2008 R2 :

      • Dans la barre des tâches, cliquez sur Démarrer, pointez sur Outils d’administration, puis cliquez sur Gestionnaire Internet Information Services (IIS).
    • Si vous utilisez Windows Vista ou Windows 7 :

      • Dans la barre des tâches, cliquez sur Démarrer, puis sur Panneau de configuration.
      • Double-cliquez sur Outils d’administration, puis sur Gestionnaire Internet Information Services (IIS).
  2. Dans le volet Connexions, développez le nom du serveur, développez Sites, accédez au niveau dans le volet de hiérarchie que vous souhaitez configurer, puis cliquez sur le site web ou l’application web.

  3. Faites défiler jusqu’à la section Sécurité dans le volet Accueil, puis double-cliquez sur Authentification.

  4. Dans le volet Authentification, sélectionnez Authentification anonyme, puis cliquez sur Désactiver dans le volet Actions.
    Screenshot that shows the Authentication pane. Anonymous Authentication is enabled and selected.

Comment modifier les informations d’identification d’authentification anonyme à partir du compte IUSR

  1. Ouvrez le Gestionnaire Internet Information Services (IIS) :

    • Si vous utilisez Windows Server 2012 ou Windows Server 2012 R2 :

      • Dans la barre des tâches, cliquez sur Gestionnaire de serveur, sur Outils, puis sur Gestionnaire Internet Information Services (IIS).
    • Si vous utilisez Windows 8 ou Windows 8.1 :

      • Maintenez la touche Windows enfoncée, appuyez sur la lettre X, puis cliquez sur Panneau de configuration.
      • Cliquez sur Outils d’administration, puis double-cliquez sur Gestionnaire Internet Information Services (IIS).
    • Si vous utilisez Windows Server 2008 ou Windows Server 2008 R2 :

      • Dans la barre des tâches, cliquez sur Démarrer, pointez sur Outils d’administration, puis cliquez sur Gestionnaire Internet Information Services (IIS).
    • Si vous utilisez Windows Vista ou Windows 7 :

      • Dans la barre des tâches, cliquez sur Démarrer, puis sur Panneau de configuration.
      • Double-cliquez sur Outils d’administration, puis sur Gestionnaire Internet Information Services (IIS).
  2. Dans le volet Connexions, développez le nom du serveur, développez Sites, accédez au niveau dans le volet de hiérarchie que vous souhaitez configurer, puis cliquez sur le site web ou l’application web.

  3. Faites défiler jusqu’à la section Sécurité dans le volet Accueil, puis double-cliquez sur Authentification.

  4. Dans le volet Authentification, sélectionnez Authentification anonyme, puis cliquez sur Modifier... dans le volet Actions.

  5. Dans la boîte de dialogue Modifier les informations d’identification d’authentification anonyme, effectuez l’une des opérations suivantes :

    • Sélectionnez Identité du pool d’applications pour utiliser l’identité définie pour le pool d’applications, puis cliquez sur OK.
      Screenshot that shows the Edit Anonymous Authentication Credentials dialog box. Application pool identity is selected.

    • Cliquez sur Définir... puis, dans la boîte de dialogue Définir les informations d’identification, entrez le nom d’utilisateur du compte dans la zone Nom d’utilisateur, entrez le mot de passe du compte dans les zones Mot de passe et Confirmer le mot de passe, cliquez sur OK, puis cliquez à nouveau sur OK.
      Screenshot that shows the Set Credentials dialog box.

      Remarque

      Si vous utilisez cette procédure, accordez uniquement les privilèges minimaux au nouveau compte sur l’ordinateur de serveur IIS.


Comment activer l’authentification Windows pour un site web, une application web ou un service web

  1. Ouvrez le Gestionnaire Internet Information Services (IIS) :

    • Si vous utilisez Windows Server 2012 ou Windows Server 2012 R2 :

      • Dans la barre des tâches, cliquez sur Gestionnaire de serveur, sur Outils, puis sur Gestionnaire Internet Information Services (IIS).
    • Si vous utilisez Windows 8 ou Windows 8.1 :

      • Maintenez la touche Windows enfoncée, appuyez sur la lettre X, puis cliquez sur Panneau de configuration.
      • Cliquez sur Outils d’administration, puis double-cliquez sur Gestionnaire Internet Information Services (IIS).
    • Si vous utilisez Windows Server 2008 ou Windows Server 2008 R2 :

      • Dans la barre des tâches, cliquez sur Démarrer, pointez sur Outils d’administration, puis cliquez sur Gestionnaire Internet Information Services (IIS).
    • Si vous utilisez Windows Vista ou Windows 7 :

      • Dans la barre des tâches, cliquez sur Démarrer, puis sur Panneau de configuration.
      • Double-cliquez sur Outils d’administration, puis sur Gestionnaire Internet Information Services (IIS).
  2. Dans le volet Connexions, développez le nom du serveur, développez Sites, puis le site, l’application ou le service web pour lequel vous souhaitez activer l’authentification Windows.

  3. Faites défiler jusqu’à la section Sécurité dans le volet Accueil, puis double-cliquez sur Authentification.

  4. Dans le volet Authentification, sélectionnez Authentification Windows, puis cliquez sur Activer dans le volet Actions.
    Screenshot that shows the Authentication pane. Windows Authentication is disabled and selected.

Configuration

Le groupe de sections <authentication> est défini dans la section de configuration <system.webServer>. Ce groupe de sections définit les sections de configuration de tous les types d’authentification utilisateur que vous pouvez installer et activer sur votre serveur. Vous pouvez le configurer au niveau du serveur dans le fichier ApplicationHost.config et au niveau de l’application dans le fichier Web.config.

Attributs

Aucune.

Éléments enfants

Élément Description
anonymousAuthentication Élément facultatif.

Spécifie les paramètres de l’authentification anonyme.
basicAuthentication Élément facultatif.

Spécifie les paramètres de l’authentification de base.
clientCertificateMappingAuthentication Élément facultatif.

Spécifie les paramètres de l’authentification par mappage de certificat client avec Active Directory.
digestAuthentication Élément facultatif.

Spécifie les paramètres de l’authentification Digest.
iisClientCertificateMappingAuthentication Élément facultatif.

Spécifie les paramètres de l’authentification par mappage de certificat client avec IIS.
windowsAuthentication Élément facultatif.

Spécifie les paramètres de l’authentification Windows.

Exemple Configuration

L’exemple de configuration suivant désactive l’authentification anonyme pour un site nommé Contoso, puis active l’authentification de base et l’authentification Windows pour le site.

<location path="Contoso">
   <system.webServer>
      <security>
         <authentication>
            <anonymousAuthentication enabled="false" />
            <basicAuthentication enabled="true" defaultLogonDomain="Contoso" />
            <windowsAuthentication enabled="true" />
          </authentication>
      </security>
   </system.webServer>
</location>

Exemple de code

Les exemples suivants désactivent l’authentification anonyme pour un site nommé Contoso, puis activent l’authentification de base et l’authentification Windows pour le site.

AppCmd.exe

appcmd.exe set config "Contoso" -section:system.webServer/security/authentication/anonymousAuthentication /enabled:"False" /commit:apphost

appcmd.exe set config "Contoso" -section:system.webServer/security/authentication/basicAuthentication /enabled:"True" /commit:apphost

appcmd.exe set config "Contoso" -section:system.webServer/security/authentication/windowsAuthentication /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 anonymousAuthenticationSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication", "Contoso");
         anonymousAuthenticationSection["enabled"] = false;

         ConfigurationSection basicAuthenticationSection = config.GetSection("system.webServer/security/authentication/basicAuthentication", "Contoso");
         basicAuthenticationSection["enabled"] = true;

         ConfigurationSection windowsAuthenticationSection = config.GetSection("system.webServer/security/authentication/windowsAuthentication", "Contoso");
         windowsAuthenticationSection["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 anonymousAuthenticationSection As ConfigurationSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication", "Contoso")
      anonymousAuthenticationSection("enabled") = False

      Dim basicAuthenticationSection As ConfigurationSection = config.GetSection("system.webServer/security/authentication/basicAuthentication", "Contoso")
      basicAuthenticationSection("enabled") = True

      Dim windowsAuthenticationSection As ConfigurationSection = config.GetSection("system.webServer/security/authentication/windowsAuthentication", "Contoso")
      windowsAuthenticationSection("enabled") = True

      serverManager.CommitChanges()
   End Sub
End Module

JavaScript

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

var anonymousAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/anonymousAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso");
anonymousAuthenticationSection.Properties.Item("enabled").Value = false;

var basicAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/basicAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso");
basicAuthenticationSection.Properties.Item("enabled").Value = true;

var windowsAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/windowsAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso");
windowsAuthenticationSection.Properties.Item("enabled").Value = true;

adminManager.CommitChanges();

VBScript

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

Set anonymousAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/anonymousAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso")
anonymousAuthenticationSection.Properties.Item("enabled").Value = False

Set basicAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/basicAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso")
basicAuthenticationSection.Properties.Item("enabled").Value = True

Set windowsAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/windowsAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso")
windowsAuthenticationSection.Properties.Item("enabled").Value = True

adminManager.CommitChanges()