Running following on W2K3 (IIS6):
{
DirectoryEntry de = new DirectoryEntry( "IIS://scenic/W3SVC/1/root",
"administrator" , "pwd",
AuthenticationT ypes.Secure);
foreach( string myKey in de.Properties.P ropertyNames)
{
Console.WriteLi ne(myKey + " " + de.Properties[myKey].Value);
}
}
dumps :
AccessFlags 513
AccessSSLFlags 0
AppIsolated 2
AuthFlags 5
FrontPageWeb True
AppFriendlyName Default Application
AppPoolId DefaultAppPool
AppRoot /LM/W3SVC/1/ROOT
KeyType IIsWebVirtualDi r
Path d:\inetpub\wwwr oot
HttpCustomHeade rs System.Object[]
ScriptMaps System.Object[]
DefaultDoc Default.htm,Def ault.asp,index. htm,iisstart.ht m,Default.aspx
AppAllowClientD ebug False
AppAllowDebuggi ng False
AspAllowOutOfPr ocComponents True
AspAllowSession State True
AspAppServiceFl ags 0
AspBufferingLim it 4194304
AspBufferingOn True
AspCalcLineNumb er True
AspCodepage 0
AspEnableApplic ationRestart True
AspEnableAspHtm lFallback False
AspEnableChunke dEncoding True
AspEnableParent Paths False
AspEnableTypeli bCache True
AspErrorsToNTLo g False
AspExceptionCat chEnable True
AspExecuteInMTA 0
AspKeepSessionI DSecure 0
AspLCID 2048
AspLogErrorRequ ests True
AspMaxDiskTempl ateCacheFiles 2000
AspMaxRequestEn tityAllowed 204800
AspProcessorThr eadMax 25
AspQueueConnect ionTestTime 3
AspQueueTimeout -1
AspRequestQueue Max 3000
AspRunOnEndAnon ymously True
AspScriptEngine CacheMax 250
AspScriptErrorS entToBrowser True
AspScriptFileCa cheSize 500
AspScriptTimeou t 90
AspSessionMax -1
AspSessionTimeo ut 20
AspTrackThreadi ngModel False
BITSAllowOverwr ites 0
BITSHostIdFallb ackTimeout 86400
BITSServerNotif icationType 0
BITSSessionTime out 1209600
CGITimeout 300
ContentIndexed True
DirBrowseFlags 1073741886
PasswordChangeF lags 6
AnonymousUserNa me IUSR_SCENIC
AnonymousUserPa ss %Z33<cyw@;8*Rt
AspScriptErrorM essage An error occurred on the server when processing the
URL.
Please contact the system administrator.
AspScriptLangua ge VBScript
AuthChangeURL /iisadmpwd/achg.asp
AuthExpiredUnse cureURL /iisadmpwd/aexp3.asp
AuthExpiredURL /iisadmpwd/aexp.asp
AuthNotifyPwdEx pUnsecureURL /iisadmpwd/anot3.asp
AuthNotifyPwdEx pURL /iisadmpwd/anot.asp
BITSHostId
BITSMaximumUplo adSize 184467440737095 51615
BITSServerNotif icationURL
BITSSessionDire ctory BITS-Sessions
HttpExpires D, 0x15180
AdminACL System.__ComObj ect
AspDiskTemplate CacheDirectory %windir%\system 32\inetsrv\ASP Compiled
Templates
HttpErrors System.Object[]
Willy.
"Stephanie Stowe" <No****@IWishIC ould.com> wrote in message
news:Or******** ******@TK2MSFTN GP12.phx.gbl...
Hi. I am trying to read information out of the IIS metabase (v5.1).
Observe
the following code:
using System;
using System.Director yServices;
using System.Reflecti on;
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\\adm inistrator",
password, AuthenticationT ypes.Secure);
Console.WriteLi ne ( site.Path );
Console.WriteLi ne();
foreach ( string propName in site.Properties .PropertyNames)
{
Console.WriteLi ne(propName);
foreach (object value in site.Properties[propName])
{
Console.WriteLi ne("\tname = " + propName + ", value = "
+ value);
}
}
Console.WriteLi ne("Done");
}
}
}
At foreach(string propName in site.Properties .ProerptyNames)
I receive the runtime error
An unhandled exception of type 'System.NotSupp ortedException' occurred in
system.director yservices.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