AuthenticationSection Class1
Configura a autenticação ASP.NET.
Sintaxe
class AuthenticationSection : ConfigurationSectionWithCollection
Métodos
A tabela a seguir lista os métodos expostos pela classe AuthenticationSection
.
Nome | Descrição |
---|---|
Add | (Herdado de ConfigurationSectionWithCollection.) |
Limpar | (Herdado de ConfigurationSectionWithCollection .) |
Get | (Herdado de ConfigurationSectionWithCollection .) |
GetAllowDefinition | (Herdado de ConfigurationSection.) |
GetAllowLocation | (Herdado de ConfigurationSection .) |
Remover | (Herdado de ConfigurationSectionWithCollection .) |
RevertToParent | (Herdado de ConfigurationSection .) |
SetAllowDefinition | (Herdado de ConfigurationSection .) |
SetAllowLocation | (Herdado de ConfigurationSection .) |
Propriedades
A tabela a seguir lista as propriedades expostas pela classe AuthenticationSection
.
Nome | Descrição |
---|---|
Forms |
Um valor FormsAuthenticationConfiguration que configura a autenticação de formulários para o aplicativo Web. |
Location |
(Herdado de ConfigurationSection .) Uma propriedade chave. |
Mode |
Um valor sint32 de leitura/gravação que especifica o modo de autenticação para o aplicativo Web. Os valores possíveis estão listados posteriormente na seção Comentários. |
Passport |
Um valor PassportAuthentication que contém uma URL para a qual a solicitação de autenticação será redirecionada. |
Path |
(Herdado de ConfigurationSection .) Uma propriedade chave. |
SectionInformation |
(Herdado de ConfigurationSection .) |
Subclasses
Essa classe não contém subclasses.
Comentários
A tabela a seguir lista os possíveis valores da propriedade Mode
. O padrão é 1 (Windows
).
Valor | Palavra-chave | Descrição |
---|---|---|
0 | None |
Especifica nenhuma autenticação. |
1 | Windows |
Especifica Windows como o modo de autenticação. Esse modo se aplica quando o ASP.NET usa os métodos de autenticação Básico, Digest, Windows Integrado (NTLM/Kerberos) ou o Mapeamento de Certificado de Cliente. |
2 | Passport |
Especifica a autenticação do Microsoft Passport Network como modo de autenticação. |
3 | Forms |
Especifica a autenticação do Forms do ASP.NET como o modo de autenticação. |
Exemplo
O exemplo a seguir exibe o modo de autenticação do site da Web padrão. Se o modo de autenticação for Passport
, será exibida a URL de redirecionamento. Se o modo for Forms
, serão exibidas as informações correspondentes.
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = _
GetObject("winmgmts:root\WebAdministration")
' Get the authentication section.
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")
oSite.GetSection "AuthenticationSection", oAuthSection
' Display the path and location.
WScript.Echo "Path: " & oAuthSection.Path
WScript.Echo "Location: " & oAuthSection.Location
WScript.Echo
' Get the authentication mode and display it in text.
strAuthMode = ModeText(oAuthSection.Mode)
WScript.Echo "Authentication Mode: " & _
"[ " & strAuthMode & " ]"
' If the mode is Passport or Forms, display the
' additional information.
If strAuthMode = "Passport" Then
WScript.Echo "Passport URL: " & "[" & _
oAuthSection.Passport.RedirectUrl & "]"
ElseIf strAuthMode = "Forms" then
DisplayFormsAuthSettings(oAuthSection.Forms)
End If
' Convert the Mode enumeration values to text.
Function ModeText(enumValue)
Select Case enumValue
Case 0
ModeText = "None"
Case 1
ModeText = "Windows"
Case 2
ModeText = "Passport"
Case 3
ModeText = "Forms"
Case Else
ModeText = "Undefined enumeration value."
End Select
End Function
' Display the Forms authentication settings.
Sub DisplayFormsAuthSettings(oFormsAuthConfig)
WScript.Echo vbCrLf & "Forms Authentication Settings"
WScript.Echo "-----------------------------"
WScript.Echo "Cookieless: [ " & _
CookielessText(oFormsAuthConfig.Cookieless) & " ]"
WScript.Echo "Default Url: [ " & _
oFormsAuthConfig.DefaultUrl & " ]"
WScript.Echo "Domain: [ " & _
oFormsAuthConfig.Domain & " ]"
WScript.Echo "EnableCrossAppRedirects: [" & _
oFormsAuthConfig.EnableCrossAppRedirects & " ]"
WScript.Echo "LoginUrl: [ " & _
oFormsAuthConfig.LoginUrl & " ]"
WScript.Echo "Name: [ " & _
oFormsAuthConfig.Name & " ]"
WScript.Echo "Path: [ " & _
oFormsAuthConfig.Path & " ]"
WScript.Echo "Protection: [ " & _
ProtectionText(oFormsAuthConfig.Protection) & " ]"
WScript.Echo "RequireSSL: [ " & _
oFormsAuthConfig.RequireSSL & " ]"
WScript.Echo "SlidingExpiration: [ " & _
oFormsAuthConfig.SlidingExpiration & " ]"
WScript.Echo "Timeout: [ " & _
oFormsAuthConfig.Timeout & " ]"
DisplayCredentials(oFormsAuthConfig.Credentials)
End Sub
' Convert the Cookieless enumeration values to text.
Function CookielessText(enumValue)
Select Case enumValue
Case 0
CookielessText = "UseUri"
Case 1
CookielessText = "UseCookies"
Case 2
CookielessText = "AutoDetect"
Case 3
CookielessText = "UseDeviceProfile"
Case Else
CookielessText = "Undefined enumeration value."
End Select
End Function
' Convert the Protection enumeration values to text.
Function ProtectionText(enumValue)
Select Case enumValue
Case 0
ProtectionText = "All"
Case 1
ProtectionText = "None"
Case 2
ProtectionText = "Encryption"
Case 3
ProtectionText = "Validation"
Case Else
ProtectionText = "Undefined enumeration value."
End Select
End Function
' Display the Forms authentication credentials.
Sub DisplayCredentials(FA_Credentials)
WScript.Echo vbCrLf & "Forms Authentication Credentials"
WScript.Echo "--------------------------------"
WScript.Echo "Password Format: " & _
PwdFormatText(FA_Credentials.PasswordFormat) & VbCrLf
For Each FormsAuthUser In FA_Credentials.Credentials
WScript.Echo " Name: [ " & FormsAuthUser.Name & " ]"
WScript.Echo "Password: [ " & _
FormsAuthUser.Password& " ]"
WScript.Echo
Next
End Sub
' Convert the PasswordFormat enumeration values to text.
Function PwdFormatText(enumValue)
Select Case enumValue
Case 0
PwdFormatText = "Clear"
Case 1
PwdFormatText = "SHA1"
Case 2
PwdFormatText = "MD5"
Case Else
PwdFormatText = "Undefined enumeration value."
End Select
End Function
Hierarquia de herança
ConfigurationSectionWithCollection
AuthenticationSection
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 BasicAuthenticationSection
Classe ClientCertificateMappingAuthenticationSection
Classe ConfigurationSectionWithCollection
Classe DigestAuthenticationSection
Classe FormsAuthenticationConfiguration
Classe FormsAuthenticationCredentials
Classe FormsAuthenticationUser
Classe IisClientCertificateMappingAuthenticationSection
Classe PassportAuthentication
Classe WindowsAuthenticationSection