SectionInformation.RequirePermission Propriedade
Definição
Obtém um valor que indica se a seção de configuração associada requer permissões de acesso.Gets a value that indicates whether the associated configuration section requires access permissions.
public:
property bool RequirePermission { bool get(); void set(bool value); };
public bool RequirePermission { get; set; }
member this.RequirePermission : bool with get, set
Public Property RequirePermission As Boolean
Valor da propriedade
true se o requirePermission atributo for definido como true; caso contrário, false.true if the requirePermission attribute is set to true; otherwise, false. O padrão é true.The default is true.
Exceções
Os conflitos de valor selecionados com um valor que já está definido.The selected value conflicts with a value that is already defined.
Exemplos
O exemplo a seguir mostra dois níveis de confiança possíveis para um aplicativo Web quando a RequirePermission propriedade da appSettings seção é true .The following example shows two possible trust levels for a Web application when the RequirePermission property of the appSettings section is true.
<system.web>
// With the following trust value
// the code below works.
<trust level="Full" />
</system.web>
<system.web>
// With the following trust value
// the code below does not work.
<trust level="Medium" />
</system.web>
O exemplo a seguir mostra o código que é executado sem erros quando o nível de confiança é definido como completo.The following example shows code that runs without errors when the trust level is set to full. Caso contrário, o código resultará em um erro.Otherwise, the code results in an error.
AppSettingsSection apSection =
ConfigurationManager.GetSection("appSettings") as AppSettingsSection;
NameValueCollection apSectionCollection =
ConfigurationManager.AppSettings;
Dim apSection As AppSettingsSection = _
TryCast(ConfigurationManager.GetSection("appSettings"),
AppSettingsSection)
Dim apSectionCollection As NameValueCollection = _
ConfigurationManager.AppSettings
Comentários
Quando RequirePermission é definido como true , os GetSection métodos são restritos pela configuração de nível de confiança do aplicativo.When RequirePermission is set to true, the GetSection methods are restricted by the trust level setting of the application. Isso significa que métodos ou propriedades que permitem acesso a manipuladores de seção de configuração são restritos pelo nível de confiança definido para o aplicativo Web.This means that methods or properties that allow access to configuration section handlers are restricted by the trust level set for the Web application.
Observação
Como confiança alta e completa são os únicos níveis que permitem o acesso a arquivos fora do domínio do aplicativo atual, um aplicativo pode usar manipuladores de seção de configuração somente nesses níveis de confiança.Because high and full trust are the only levels that allow access to files outside the current application domain, an application can use configuration section handlers only at these trust levels.
Quando RequirePermission é definido como false , o acesso aos dados de configuração não é restrito pelas configurações de nível de confiança do aplicativo.When RequirePermission is set to false, the access to the configuration data is not restricted by the application's trust level settings.
Observação
As permissões apropriadas de ACL de arquivo (lista de controle de acesso) ainda são necessárias, independentemente da RequirePermission configuração.The appropriate file ACL (Access Control List) permissions are still required, regardless of the RequirePermission setting. As permissões de ACL determinam quem pode acessar o arquivo de configuração.ACL permissions determine who can access the configuration file.