Partager via


Méthode ConfigurationSection.GetAllowLocation

Récupère l’attribut allowLocation pour une section de configuration.

Syntaxe

ConfigurationSection.GetAllowLocation AllowLocation  
ConfigurationSection.GetAllowLocation(AllowLocation);  

Paramètres

Nom Définition
AllowLocation Une variable string qui reçoit l’attribut allowLocation retourné par la méthode GetAllowLocation. Les valeurs d’attribut possibles sont « true » ou « false ». La valeur par défaut est "true". Remarque : Ce paramètre est un string, et non 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 GetAllowLocation 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.GetAllowLocation strAnonAuthAllowLocation  

La syntaxe suivante échoue, car elle tente d’appeler GetAllowLocation 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.GetAllowLocation strAnonAuthAllowLocation  

Exemple

L’exemple suivant affiche l’attribut allowLocation de 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")  
  
' Get the allowLocation attribute.  
oAnonAuth.GetAllowLocation strAnonAuthAllowLocation  
  
' Display the allowLocation attribute.  
WScript.Echo _  
    "Anonymous Authentication Allow Location: " & _  
        strAnonAuthAllowLocation  
  

Spécifications

Type Description
Client - IIS 7.0 sous Windows Vista
- IIS 7.5 sous Windows 7
- IIS 8.0 sous Windows 8
- IIS 10.0 sous Windows 10
Serveur - IIS 7.0 sous Windows Server 2008
- IIS 7.5 sous Windows Server 2008 R2
- IIS 8.0 sous Windows Server 2012
- IIS 8.5 sous 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.GetAllowDefinition