Partager via


Méthode ConfigurationSection.SetAllowLocation

Définit l’attribut d’une section allowLocation de configuration.

Syntaxe

ConfigurationSection.SetAllowLocation(AllowLocation)  
ConfigurationSection.SetAllowLocation(AllowLocation);  

Paramètres

Nom Définition
AllowLocation Variable string sensible à la casse qui définit l’attribut allowLocation pour la section de configuration. Les valeurs d’attribut possibles sont « true » ou « false ». La valeur par défaut est "true". Remarque : Ce paramètre est un string, pas un boolean.

Valeur de retour

Cette méthode ne retourne pas de valeur.

Notes

L’attribut allowLocation spécifie si une section de configuration peut apparaître à l’intérieur d’une paire de balises d’emplacement.

Étant donné que SetAllowLocation est une méthode statique, vous devez l’appeler en obtenant un objet de classe, comme dans l’exemple suivant.

' Correct syntax:  
Set oAnonAuth = oWebAdmin.Get("AnonymousAuthenticationSection")  
oAnonAuth.SetAllowLocation "false"  

La syntaxe suivante échoue, car elle tente d’appeler SetAllowLocation sur une instance concrète de la classe Site. L’appel à la méthode entraîne une erreur « SWbemObjectEx : Introuvable ».

  
' Incorrect syntax:  
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")  
oSite.GetSection "AnonymousAuthenticationSection", oAnonAuth  
oAnonAuth.SetAllowLocation "false"  

Exemple

L’exemple suivant définit l’attribut allowLocation pour la section configuration de l’authentification anonyme.

' Get the WebAdministration namespace.  
Set oWebAdmin = GetObject( _  
    "winmgmts:root\WebAdministration")  
  
' Get the AnonymousAuthenticationSection.  
Set oAnonAuth = oWebAdmin.Get( _  
    "AnonymousAuthenticationSection")  
  
' Set the allowLocation attribute.  
oAnonAuth.GetAllowLocation "false"  
  

Spécifications

Type Description
Client - IIS 7.0 sur Windows Vista
- IIS 7.5 sous Windows 7
- IIS 8.0 sous Windows 8
- IIS 10.0 sous Windows 10
Serveur - IIS 7.0 sur Windows Server 2008
- IIS 7.5 sur Windows Server 2008 R2
- IIS 8.0 sur Windows Server 2012
- IIS 8.5 sur Windows Server 2012 R2
- IIS 10.0 sous Windows Server 2016
Produit - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
Fichier MOF WebAdministration.mof

Voir aussi

Classe AnonymousAuthenticationSection
Classe ConfigurationSection
Méthode ConfigurationSection.GetAllowLocation