S
Stephanie Stowe
Hi. I am trying to read information out of the IIS metabase (v5.1). Observe
the following code:
using System;
using System.DirectoryServices;
using System.Reflection;
namespace ADSI1
{
class ConfigIIS
{
[STAThread]
static void Main(string[] args)
{
string serverName = "localhost";
string password = "Y@ms,M0s";
DirectoryEntry site = new DirectoryEntry
("IIS://localhost/W3SVC/1/Root/Stowesoft", "localhost\\administrator",
password, AuthenticationTypes.Secure);
Console.WriteLine ( site.Path );
Console.WriteLine();
foreach ( string propName in site.Properties.PropertyNames)
{
Console.WriteLine(propName);
foreach (object value in site.Properties[propName])
{
Console.WriteLine("\tname = " + propName + ", value = "
+ value);
}
}
Console.WriteLine("Done");
}
}
}
At foreach(string propName in site.Properties.ProerptyNames)
I receive the runtime error
An unhandled exception of type 'System.NotSupportedException' occurred in
system.directoryservices.dll
Additional information: The directory cannot report the number of
properties.
I do not NEED to iterate through the properties so much as check the values
of the properties that I want. My underlying goal is to compare the IIS
setup on a production server to the known desired values. So I want to be
able to read the IIS metabase for virtual root. So for a given virtual root,
what are the application settings, what is the local path, authentication
information...
I don't know how to find out these property names. So I either
- need to learn what is wrong with my code for iterating through the
properties OR
- need to know the name of the properties (from some documentation I could
not find that perhaps one could point me to) available so that I can get the
values directly.
Thanks for your help!
Stephanie
the following code:
using System;
using System.DirectoryServices;
using System.Reflection;
namespace ADSI1
{
class ConfigIIS
{
[STAThread]
static void Main(string[] args)
{
string serverName = "localhost";
string password = "Y@ms,M0s";
DirectoryEntry site = new DirectoryEntry
("IIS://localhost/W3SVC/1/Root/Stowesoft", "localhost\\administrator",
password, AuthenticationTypes.Secure);
Console.WriteLine ( site.Path );
Console.WriteLine();
foreach ( string propName in site.Properties.PropertyNames)
{
Console.WriteLine(propName);
foreach (object value in site.Properties[propName])
{
Console.WriteLine("\tname = " + propName + ", value = "
+ value);
}
}
Console.WriteLine("Done");
}
}
}
At foreach(string propName in site.Properties.ProerptyNames)
I receive the runtime error
An unhandled exception of type 'System.NotSupportedException' occurred in
system.directoryservices.dll
Additional information: The directory cannot report the number of
properties.
I do not NEED to iterate through the properties so much as check the values
of the properties that I want. My underlying goal is to compare the IIS
setup on a production server to the known desired values. So I want to be
able to read the IIS metabase for virtual root. So for a given virtual root,
what are the application settings, what is the local path, authentication
information...
I don't know how to find out these property names. So I either
- need to learn what is wrong with my code for iterating through the
properties OR
- need to know the name of the properties (from some documentation I could
not find that perhaps one could point me to) available so that I can get the
values directly.
Thanks for your help!
Stephanie