Problems with ADSI on Win2000 & IIS

7 views
Skip to first unread message

Vance Kessler

unread,
Aug 1, 2003, 4:34:21 PM8/1/03
to
I have code that works fine on XP Pro but dies on Windows 2000 server.
At least, it dies the second time I run it. The first time I run I
create a new websiteand create the Root directory and set the Path
property (through Properties["Path"]). That works just fine. The
second time I run this app it does not create the sites but does try
to set the path property. It works fine on XP(SP1) but I get an
exception on Win2000(SP4) when I do this.


I found a test program to set the Path property and it also gets the
exception below:

Unhandled Exception: System.Runtime.InteropServices.COMException
(0x80005006): Exception from HRESULT: 0x80005006.
at System.DirectoryServices.Interop.IAds.GetEx(String bstrName)
at System.DirectoryServices.PropertyValueCollection.PopulateList()
at System.DirectoryServices.PropertyCollection.get_Item(String
propertyName)
at ADWrite.Main(String[] args)

Even running this app ON my XP box but referencing the Win2000 box
gives me the same error. I am running my test program below with the
following options (and yes the site number is 4 on the WIn2000 box):

SetADSI IIS://vkessler/W3SVC/4/Root Path c:\Temp

If I run this on the XP box and change the Root Path there it works
fine.

Here is the code for the test app (compiles with just csc.exe):
--------------------------------------------------------------
using System;
using System.DirectoryServices;

public class ADWrite {
public static void Main(String[] args) {
if ( args.Length!=3 ) {
Console.WriteLine("Usage: " +
Environment.GetCommandLineArgs()[0] + " <ad_path> <property>
<value>");
return;
}
DirectoryEntry objDirEnt = new DirectoryEntry(args[0]);
Console.WriteLine("Name = " + objDirEnt.Name);
Console.WriteLine("Path = " + objDirEnt.Path);
Console.WriteLine("SchemaClassName = " +
objDirEnt.SchemaClassName);
Console.WriteLine(args[1] + " = " +
(objDirEnt.Properties[args[1]][0]).ToString());
Console.WriteLine("... changing to ");
(objDirEnt.Properties[args[1]])[0] = args[2];
objDirEnt.CommitChanges();
Console.WriteLine(args[1] + " = " +
(objDirEnt.Properties[args[1]][0]).ToString());
}
}

Vance Kessler

unread,
Aug 2, 2003, 10:17:12 AM8/2/03
to
I discovered something VERY interesting. This only gives an error for
the Path property of the Root directory. I can change the values of
all other properties just fine. If I skip setting this one property
my program runs great.

Vance Kessler

unread,
Aug 19, 2003, 8:47:18 AM8/19/03
to
OK, problem solved and it is pretty strange. It turns out there is a
value that needs to be set for the KeyType that determine the kind of
object you are dealing with. Well, for some reason the Root node was
created with out this key. Once I added this key and set it to
IISWebVirtualDir things worked great.
Reply all
Reply to author
Forward
0 new messages