Microsoft KB Archive/321768

= 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 =

Article ID: 321768

Article Last Modified on 3/3/2005

-

APPLIES TO


 * Microsoft Internet Information Server 4.0
 * Microsoft Internet Information Services 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 &quot;Configuration Backup/Restore&quot; Help topic in Microsoft Management Console (MMC).



SYMPTOMS
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.



CAUSE
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.



MORE INFORMATION
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:
 * PATH
 * KEYTYPE
 * ACCESSFLAGS

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 &quot;Iisserver01.&quot; 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 = &quot;iisserver01&quot; 'This must be the identifier for the site that you are working with. sVirtualSiteName = &quot;1&quot; sPhysicalPath = &quot;c:\Inetpub\wwwroot\mydir&quot; sname = &quot;mydir&quot; sMetaPath = &quot;IIS://&quot; & servername & &quot;/W3SVC/&quot; & sVirtualSiteName & &quot;/Root&quot; 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(&quot;IIsWebVirtualDir&quot;, sname)

arrScriptMaps(0) = &quot;.asp, %SystemRoot%\System32\inetsrv\asp.dll,1,GET,HEAD,POST,TRACE&quot;

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 = &quot;iisserver01&quot; 'This must be the identifier for the site that you are working with. sVirtualSiteName = &quot;1&quot; sPhysicalPath = &quot;c:\Inetpub\wwwroot\mykeydir&quot; sname = &quot;mykeydir&quot; sMetaPath = &quot;IIS://&quot; & servername & &quot;/W3SVC/&quot; & sVirtualSiteName & &quot;/Root&quot; Set oParent = GetObject(sMetaPath) If IsObject(oParent) Then Set oDir = oParent.Create(&quot;IIsWebVirtualDir&quot;, sname) oDir.SetInfo ' This line is added to resolve this issue.

arrScriptMaps(0) = &quot;.asp, %SystemRoot%\System32\inetsrv\asp.dll,1,GET,HEAD,POST,TRACE&quot;

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

Keywords: kbtshoot kbprb KB321768

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.