The KeyType property may be missing when you create a virtual directory by using Active Directory Service Interfaces (ADSI) that are provided with Internet Information Server 4.0 and with Internet Information Server 5.0 (321768)
The information in this article applies to:
- Microsoft Internet Information Server 4.0
- Microsoft Internet Information Server 5.0
This article was previously published under Q321768 Important This article contains information about editing the metabase. Before you edit the metabase, verify that you have a backup copy that you can restore if a problem occurs. For information about how to do this, see the "Configuration Backup/Restore" Help topic in Microsoft Management Console (MMC).
SYMPTOMSThe 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.CAUSEThis 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.
MORE INFORMATIONWarning 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: - Use the Adsutil utility. For example, type the following command at a command prompt:
adsutil ENUM \w3svc\1\root - Use the MetaEdit utility.
For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
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
Modification Type: | Major | Last Reviewed: | 3/3/2005 |
---|
Keywords: | kbtshoot kbprb KB321768 kbAudDeveloper kbAudITPRO |
---|
|