共用方式為


VirtualDirectoryElementDefaults Class1

公開 IIS 虛擬目錄的預設組態設定。

Syntax

class VirtualDirectoryElementDefaults : EmbeddedObject  

方法

這個類別不包含任何方法。

屬性

下表列出 類別所 VirtualDirectoryElementDefaults 公開的屬性。

名稱 描述
AllowSubDirConfig 讀取/寫入 boolean 值。 true 如果 IIS 預設會在低於目前層級的內容目錄中尋找Web.config檔案,則為 ; false 如果 IIS 在低於目前層級的目錄中尋找這些檔案,則為 。
LogonMethod 讀取/寫入 sint32 列舉,指定使用者本機登入的預設方法。 登入類型會決定是否可以從遠端使用產生的權杖。 後續的一節會列出可能的值。
Password 讀取/寫入 string 值,指定存取虛擬根目錄的預設加密密碼。 預設值為 null
Path 包含預設虛擬目錄路徑的讀取/寫入 string 值。
PhysicalPath 讀取/寫入 string 值,指定與虛擬目錄相關聯的預設實體路徑。
UserName 讀取/寫入 string 值,指定有權存取虛擬目錄中任何組態檔或內容的預設使用者。 預設值為 null

子類別

這個類別不包含子類別。

備註

這個類別的實例包含在 VirtualDirectoryDefaults伺服器台和 應用程式 類別的 屬性中。

下表包含 屬性的可能值和關鍵字 LogonMethod 。 預設值為 3 (ClearText) 。 如需詳細資訊,請參閱 LogonUserEx 函 式。

關鍵字 描述
0 互動式 可讓使用者透過終端伺服器、遠端殼層或類似的程式以互動方式登入。 由於此登入類型會快取中斷連線作業的登入資訊,因此效能可能會受到影響。 因此,這種登入類型不適用於用戶端/伺服器應用程式,例如郵件伺服器。
1 Batch 可讓使用者透過批次伺服器登入,而使用者不需要使用者介入即可執行進程。 此登入類型適用于一次處理許多純文字驗證嘗試的伺服器,例如郵件或 Web 服務器。 此登入類型不會快取認證。
2 網路 可讓使用者透過驗證純文字密碼的高效能伺服器登入。 此登入類型不會快取認證。
3 ClearText 讓使用者使用基本驗證登入。 使用者的名稱和密碼會保留在驗證套件中,這可讓伺服器在模擬用戶端時連線到其他網路伺服器。

驗證套件是封裝驗證邏輯的 DLL,可決定是否允許使用者登入。 本機安全性授權單位 (LSA) 藉由將要求傳送至驗證套件來驗證使用者登入。 然後驗證套件會檢查登入資訊,並驗證或拒絕使用者登入嘗試。

範例

下列範例示範如何為網站上的所有虛擬目錄設定使用者名稱和密碼。 然後,它會示範如何擷取月臺的所有虛擬目錄預設值。

' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")  
  
' Get the default Web site.  
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")  
  
' Set the virtual directory defaults on the Web site.  
oSite.VirtualDirectoryDefaults.UserName = "JohnV"  
oSite.VirtualDirectoryDefaults.Password = "p@ssw0rd."  
oSite.Put_  
  
' List all the virtual directory defaults for the Web site.  
WScript.Echo "AllowSubDirConfig: " & _  
    oSite.VirtualDirectoryDefaults.AllowSubDirConfig  
WScript.Echo "LogonMethod: " & _  
    GetLogonMethodText(oSite.VirtualDirectoryDefaults.LogonMethod)  
WScript.Echo "Password: " & oSite.VirtualDirectoryDefaults.Password  
WScript.Echo "Path: " & oSite.VirtualDirectoryDefaults.Path  
WScript.Echo "PhysicalPath: " & _  
    oSite.VirtualDirectoryDefaults.PhysicalPath  
WScript.Echo "UserName: " & oSite.VirtualDirectoryDefaults.UserName  
  
' This helper function converts the LogonMethod value to text.  
Function GetLogonMethodText(LogonMethodValue)  
    Select Case LogonMethodValue  
        Case 0  
            GetLogonMethodText = "Interactive"  
        Case 1  
            GetLogonMethodText = "Batch"  
        Case 2  
            GetLogonMethodText = "Network"  
        Case 3  
            GetLogonMethodText = "ClearText"  
        Case Else  
            GetLogonMethodText = "Unknown logon method."  
    End Select  
End Function  
  

繼承階層架構

EmbeddedObject

VirtualDirectoryElementDefaults

規格需求

類型 描述
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

另請參閱

應用程式類別
EmbeddedObject 類別
伺服器類別
月臺類別
VirtualDirectory 類別
LogonUserEx