すべての仮想ディレクトリとそのサブディレクトリとファイルを(再帰的に)参照する次のプログラムがあります。
static void Main(string[] args)
{
string serverName = Environment.MachineName;
DirectoryEntry dir = new DirectoryEntry("IIS://" + serverName + "/W3SVC/1/ROOT", @"adminusername", @"password");
dir.AuthenticationType = AuthenticationTypes.Secure;
PrintChildren(dir, 0);
}
private static void PrintChildren(DirectoryEntry entry,int level)
{
foreach (DirectoryEntry child in entry.Children)
{
Console.WriteLine("");
Console.WriteLine("|");
for (int i = 0; i < level; i++)
{
Console.Write("----");
}
Console.Write(child.Name);
if (child.Children != null)
{
PrintChildren(child,level + 1);
}
}
}
現在、このプログラムはすべての仮想ディレクトリを一覧表示しますが、仮想ディレクトリのサブディレクトリを一覧表示するのはごくわずかです (私が確認したそのようなディレクトリでは、IIS で匿名アクセスが有効になっています)。
このプログラムが IIS のすべてのコンテンツを参照できるようにするにはどうすればよいですか? 提供/設定できるその他のセキュリティ設定はありますか?