VirtualDirectoryElementDefaults Class1

Exposes default configuration settings for IIS virtual directories.


class VirtualDirectoryElementDefaults : EmbeddedObject  


This class contains no methods.


The following table lists the properties exposed by the VirtualDirectoryElementDefaults class.

Name Description
AllowSubDirConfig A read/write boolean value. true if by default IIS looks for Web.config files in content directories lower than the current level; false if IIS does not look for these files in directories lower than the current level.
LogonMethod A read/write sint32 enumeration that specifies the default method by which a user is locally logged on. The type of logon will determine whether the resulting token can also be used remotely. The possible values are listed later in the Remarks section.
Password A read/write string value that specifies the default encrypted password for access to the virtual root directory. The default is null.
Path A read/write string value that contains the default virtual directory path.
PhysicalPath A read/write string value that specifies the default physical path that is associated with the virtual directory.
UserName A read/write string value that specifies a default user who has rights to access any configuration files or content in a virtual directory. The default is null.


This class contains no subclasses.


Instances of this class are contained in the VirtualDirectoryDefaults property of the Server, Site, and Application classes.

The following table contains the possible values and keywords for the LogonMethod property. The default is 3 (ClearText). For more information, see the LogonUserEx function.

Value Keyword Description
0 Interactive Enables the user to log on interactively through a terminal server, remote shell, or similar process. Because this logon type caches logon information for disconnected operations, performance may be affected. This logon type is, therefore, inappropriate for client/server applications, such as mail servers.
1 Batch Enables the user to log on through a batch server, where processes can be executed for the user without the user's intervention. This logon type is appropriate for servers, such as mail or Web servers, that process many plaintext authentication attempts at a time. Credentials are not cached for this logon type.
2 Network Enables the user to log on through a high-performance server that authenticates plaintext passwords. Credentials are not cached for this logon type.
3 ClearText Enables the user to log on by using Basic authentication. The user's name and password are preserved in an authentication package, which allows the server to make connections to other network servers while impersonating the client.

An authentication package is a DLL that encapsulates the authentication logic that determines whether to permit a user to log on. Local Security Authority (LSA) authenticates a user logon by sending the request to an authentication package. The authentication package then examines the logon information and either authenticates or rejects the user logon attempt.


The following example shows how to set the user name and password for all virtual directories on a Web site. It then shows how to retrieve all the virtual directory defaults for the site.

' 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."  
' List all the virtual directory defaults for the Web site.  
WScript.Echo "AllowSubDirConfig: " & _  
WScript.Echo "LogonMethod: " & _  
WScript.Echo "Password: " & oSite.VirtualDirectoryDefaults.Password  
WScript.Echo "Path: " & oSite.VirtualDirectoryDefaults.Path  
WScript.Echo "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  

Inheritance Hierarchy




Type Description
Client - IIS 7.0 on Windows Vista
- IIS 7.5 on Windows 7
- IIS 8.0 on Windows 8
- IIS 10.0 on Windows 10
Server - IIS 7.0 on Windows Server 2008
- IIS 7.5 on Windows Server 2008 R2
- IIS 8.0 on Windows Server 2012
- IIS 8.5 on Windows Server 2012 R2
- IIS 10.0 on Windows Server 2016
Product - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
MOF file WebAdministration.mof

See Also

Application Class
EmbeddedObject Class
Server Class
Site Class
VirtualDirectory Class