Compartilhar via


Método ConfigurationSection.SetAllowLocation

Define o atributo allowLocation para uma seção de configuração.

Sintaxe

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

Parâmetros

Nome Definição
AllowLocation Uma variável string que diferencia maiúsculas de minúsculas que define o atributo allowLocation para a seção de configuração. Os valores possíveis são "true" ou "false". O padrão é "true". Observação: este parâmetro é string e não boolean.

Valor de retorno

Esse método não retorna um valor.

Comentários

O atributo allowLocation especifica se uma seção de configuração pode aparecer dentro de um par de tags de localização.

Como SetAllowLocation é um método estático, será necessário chamá-lo obtendo um objeto de classe, conforme o exemplo a seguir.

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

A sintaxe a seguir falha porque tenta chamar SetAllowLocation em uma instância concreta da classe Site. A chamada para o método causará um erro "SWbemObjectEx: não encontrado".

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

Exemplo

O exemplo a seguir define o atributo allowLocation para a seção Configuração de autenticação anônima.

' 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"  
  

Requisitos

Tipo Descrição
Cliente – IIS 7.0 no Windows Vista
– IIS 7.5 no Windows 7
– IIS 8.0 no Windows 8
– IIS 10.0 no Windows 10
Servidor – IIS 7.0 no Windows Server 2008
– IIS 7.5 no Windows Server 2008 R2
– IIS 8.0 no Windows Server 2012
– IIS 8.5 no Windows Server 2012 R2
– IIS 10.0 no Windows Server 2016
Product – IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
Arquivo MOF WebAdministration.mof

Confira também

Classe AnonymousAuthenticationSection
Classe ConfigurationSection
Método ConfigurationSection.GetAllowLocation