AuthenticationSection Class1
配置 ASP.NET 身份验证。
语法
class AuthenticationSection : ConfigurationSectionWithCollection
方法
下表列出了 AuthenticationSection
类公开的方法。
名称 | 说明 |
---|---|
添加 | (继承自 ConfigurationSectionWithCollection。) |
清除 | (从 ConfigurationSectionWithCollection 继承。) |
Get | (从 ConfigurationSectionWithCollection 继承。) |
GetAllowDefinition | (继承自 ConfigurationSection。) |
GetAllowLocation | (从 ConfigurationSection 继承。) |
删除 | (从 ConfigurationSectionWithCollection 继承。) |
RevertToParent | (从 ConfigurationSection 继承。) |
SetAllowDefinition | (从 ConfigurationSection 继承。) |
SetAllowLocation | (从 ConfigurationSection 继承。) |
属性
下表列出了 AuthenticationSection
类公开的属性。
名称 | 描述 |
---|---|
Forms |
一个 FormsAuthenticationConfiguration 值,该值为 Web 应用程序配置窗体身份验证。 |
Location |
(继承自 ConfigurationSection 。)一个键属性。 |
Mode |
一个读/写 sint32 值,该值为 Web 应用程序指定身份验证模式。 后文的“备注”部分列出了可能的值。 |
Passport |
一个 PassportAuthentication 值,该值包含一个身份验证请求将重定向到的 URL。 |
Path |
(继承自 ConfigurationSection 。)一个键属性。 |
SectionInformation |
(从 ConfigurationSection 继承。) |
子类
此类不包含子类。
注解
下表列出了 Mode
属性的可能值。 默认值为 1 (Windows
)。
值 | 关键字 | 说明 |
---|---|---|
0 | None |
不指定身份验证。 |
1 | Windows |
将 Windows 指定为身份验证模式。 ASP.NET 使用基本、简要、集成 Windows (NTLM/Kerberos) 或客户端证书映射身份验证方法时,此模式适用。 |
2 | Passport |
将 Microsoft Passport 网络身份验证指定为身份验证模式。 |
3 | Forms |
将 ASP.NET 窗体身份验证指定为身份验证模式。 |
示例
以下示例显示默认网站的身份验证模式。 如果身份验证模式为 Passport
,则显示重定向 URL。 如果模式为 Forms
,则显示相应的信息。
' 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
继承层次结构
ConfigurationSectionWithCollection
AuthenticationSection
要求
类型 | 描述 |
---|---|
客户端 | - IIS 7.0(在 Windows Vista 上) - IIS 7.5(在 Windows 7 上) - IIS 8.0(在 Windows 8 上) - IIS 10.0(在 Windows 10 上) |
服务器 | - IIS 7.0(在 Windows Server 2008 上) - IIS 7.5(在 Windows Server 2008 R2 上) - IIS 8.0(在 Windows Server 2012 上) - IIS 8.5(在 Windows Server 2012 R2 上) - IIS 10.0(在 Windows Server 2016 上) |
产品 | - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0 |
MOF 文件 | WebAdministration.mof |
另请参阅
AnonymousAuthenticationSection 类
BasicAuthenticationSection 类
ClientCertificateMappingAuthenticationSection 类
ConfigurationSectionWithCollection 类
DigestAuthenticationSection 类
FormsAuthenticationConfiguration 类
FormsAuthenticationCredentials 类
FormsAuthenticationUser 类
IisClientCertificateMappingAuthenticationSection 类
PassportAuthentication 类
WindowsAuthenticationSection 类