The
KeyType property may be missing when you create a virtual directory by using Active Directory Service Interfaces (ADSI) that are provided with Microsoft Internet Information Server (IIS) 4.0 and with Internet Information Server 5.0. You find that the
KeyType property may be missing when you try to set the attributes of the virtual directory.
This problem occurs when you do the following:
- You use an IIS ADSI provider.
- You call the Create method of the IISAdmin object.
- You do not immediately call the SetInfo method of the IISAdmin object.
Warning If you edit the metabase incorrectly, you can cause serious problems that may require you to reinstall any product that uses the metabase. Microsoft cannot guarantee that problems that result if you incorrectly edit the metabase can be solved. Edit the metabase at your own risk.
Note Always back up the metabase before you edit it.
The
KeyType property specifies the kind of key that is created. Also, the
KeyType property identifies the properties of the key. For example, a Web server has an IP address and a port. However, a virtual directory does not. Keys cannot be inherited. Keys must be specified when a new key is created.
The following keys are required for a virtual root directory to correctly function:
The following Microsoft Visual Basic code example illustrates the behavior that occurs when you call the
Create method of the
IISAdmin object. Then, you call additional statements before you call the
SetInfo method of the
IISAdmin object. This code example creates a virtual directory under the specified Web server that does not have the
KeyType property. In this code example, the Web server is named "Iisserver01." To view the metabase properties of the directory, use one of the following methods:
For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
240225
(http://support.microsoft.com/kb/240225/
)
Description of Adsutil and MetaEdit utilities used to modify the metabase
'This code does not include the KeyType property in your virtual directory.
Dim arrScriptMaps
ReDim arrScriptMaps(1)
Dim servername As String
Dim sVirtualSiteName As String
Dim sPhysicalPath As String
Dim sMetaPath As String
Dim oParent As Object
Dim oDir As Object
Dim sname as String
servername = "iisserver01"
'This must be the identifier for the site that you are working with.
sVirtualSiteName = "1"
sPhysicalPath = "c:\Inetpub\wwwroot\mydir"
sname = "mydir"
sMetaPath = "IIS://" & servername & "/W3SVC/" & sVirtualSiteName & "/Root"
Set oParent = GetObject(sMetaPath)
If IsObject(oParent) Then
'This is the Create method. The SetInfo method must be the next line.
Set oDir = oParent.Create("IIsWebVirtualDir", sname)
arrScriptMaps(0) = ".asp, %SystemRoot%\System32\inetsrv\asp.dll,1,GET,HEAD,POST,TRACE"
With oDir
.AccessRead = True
.AccessScript = True
.AccessWrite = True
.AuthNTLM = False
.AuthAnonymous = False
.AuthBasic = True
.AppCreate True
.Path = sPhysicalPath
.AppFriendlyName = sname
.AppIsolated = 0
.ScriptMaps = arrScriptMaps
'This is the SetInfo method. It must be called after the Create method.
.SetInfo
End With
End if
In the following code example, the code is the same as the first code example except that the call to the
SetInfo method follows the
Create method of the
IISAdmin object. If you call the
SetInfo method immediately after you call the
Create method, the
KeyType property is available.
Dim arrScriptMaps
ReDim arrScriptMaps(1)
Dim servername As String
Dim sVirtualSiteName As String
Dim sPhysicalPath As String
Dim sMetaPath As String
Dim oParent As Object
Dim oDir As Object
Dim sname as String
servername = "iisserver01"
'This must be the identifier for the site that you are working with.
sVirtualSiteName = "1"
sPhysicalPath = "c:\Inetpub\wwwroot\mykeydir"
sname = "mykeydir"
sMetaPath = "IIS://" & servername & "/W3SVC/" & sVirtualSiteName & "/Root"
Set oParent = GetObject(sMetaPath)
If IsObject(oParent) Then
Set oDir = oParent.Create("IIsWebVirtualDir", sname)
oDir.SetInfo ' This line is added to resolve this issue.
arrScriptMaps(0) = ".asp, %SystemRoot%\System32\inetsrv\asp.dll,1,GET,HEAD,POST,TRACE"
With oDir
.AccessRead = True
.AccessScript = True
.AccessWrite = True
.AuthNTLM = False
.AuthAnonymous = False
.AuthBasic = True
.AppCreate True
.Path = sPhysicalPath
.AppFriendlyName = sname
.AppIsolated = 0
.ScriptMaps = arrScriptMaps
.SetInfo
End With
End If