Platform SDK: Team Productivity Update

Creating and Pointing to the Virtual Directory

The document review application is a Web application that uses ASP pages hosted in Microsoft® Internet Information Server (IIS). Such an application is defined as a virtual directory and its pages. The Instantiation URL configures IIS to create a new virtual directory that points to the physical directories where the ASP pages and database reside.

The script here uses the Internet Information Server (IIS) Admin Objects to perform configuration tasks programmatically. The IIS Admin Objects are namespace providers in support of the ADSI standard for remote administration of directory service namespaces. This provides a standard syntax for addressing IIS configuration data. For more information on the relationship between ADSI and the IIS Admin Objects, see "ADSI Features" in the Internet Information Services SDK in the Microsoft Platform SDK.

Note Before calling the Instantiation URL, ensure that its virtual directory is configured as described in Configuring the Instantiation URL Virtual Directory.

The script first obtains a reference to the IIS root directory using the GetObject function. This allows the script to manipulate the configuration of the Web server root programmatically.

Next, using the IIS Admin object IISWebVirtualDirectory, the script creates and sets properties for the virtual directory that hosts the application.

' Create a new IIS Virtual Directory which points to the newly created Physical directory
Set oIIS = GetObject("IIS://" & WebServerName & "/W3SVC/1/root")  '   
Set oVirtualDir = oIIS.Create("IIsWebVirtualDir", WebVirtualDirectoryName)
oVirtualDir.Path = WebPath
oVirtualDir.AccessRead = True 
oVirtualDir.AccessWrite = False
oVirtualDir.AccessExecute = False
oVirtualDir.AuthAnonymous = False
oVirtualDir.AuthBasic = True
oVirtualDir.AuthNTLM = True
oVirtualDir.ContentIndexed = False
oVirtualDir.EnableDirBrowsing = False
oVirtualDir.AppIsolated = False

After setting the properties for the virtual directory, the script calls the InStr() function to verify that the virtual directory's directory is set to Default.asp. If InStr returns 0, then the script assigns Default.asp as the value in oVirtualDir.DefaultDoc. The script then uses the AppCreate method of the IISWebVirtualDir object to configure the application to run in-process by passing in the parameter True. (The script set a reference to the IISWebVirtualDir object in the preceding block of code.) The script sets the friendly name of the application. Then, SetInfo, an ADSI method available in the IIS Admin object model, saves these settings. Last, the script destroys the references to the IISWebVirtualDir and the IIS Web root.

If InStr(1, oVirtualDir.DefaultDoc, "Default.asp") = 0 Then
    oVirtualDir.DefaultDoc = "Default.asp, " & oVirtualDir.DefaultDoc
End If
Call oVirtualDir.AppCreate(True)
oVirtualDir.AppFriendlyName = WebVirtualDirectoryName
Call oVirtualDir.SetInfo()
Set oVirtualDir = Nothing
Set oIIS = Nothing

To follow the next steps in the script's execution, see SQL Server and the Instantiation URL.