設定 ASP.NET 驗證。
Syntax
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
規格需求
| 類型 | 描述 |
|---|---|
| Client | - Windows Vista 上的 IIS 7.0 - Windows 7 上的 IIS 7.5 - Windows 8 上的 IIS 8.0 - Windows 10上的 IIS 10.0 |
| 伺服器 | - Windows Server 2008 上的 IIS 7.0 - Windows Server 2008 R2 上的 IIS 7.5 - Windows Server 2012 上的 IIS 8.0 - Windows Server 2012 R2 上的 IIS 8.5 - Windows Server 2016上的 IIS 10.0 |
| 產品 | - 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 類別