Hi,
I am using the following logic to get the details..but I am not getting actual name of Site and Service. Any ideas on what query should I use in place of IIsWebInfo to get all the details as required.
bool mFnGetIISWebInfo(string aStrServer)
{
try
{
string lStrRemotePath = "";
string lStrOutPut = "";
lStrRemotePath = @"\\" + aStrServer.Trim() + @"\root\MicrosoftIISv2";
ManagementObjectSearcher lObjMSearcher = null;
lObjMSearcher = new ManagementObjectSearcher(lStrRemotePath, "SELECT * FROM IIsWebInfo");
foreach (ManagementObject lObject in lObjMSearcher.Get())
{
PropertyDataCollection lObjProp = lObject.Properties;
foreach (PropertyData lObjPData in lObjProp)
{
lStrOutPut += lObjPData.Name + ": " + lObjPData.Value + "
";
}
lStrOutPut += "
";
}
}
Please help out
Sreenath GPosted Jun 30, 2011, 6:27 AM
HI,
With this code, I have got all the IIS things. Now how can I filter all the WEB SERVICES In here.
ArrayList lFnGetWebServicesForServer(string aStrServer)
{
try
{
string lStrIISPath = "";
ArrayList lArLstFinalServices = new ArrayList();
lStrIISPath = @"IIS://" + aStrServer + @"/W3SVC";
DirectoryEntry lObjIIsEntities = new DirectoryEntry(lStrIISPath);
foreach (DirectoryEntry lObjEntity in lObjIIsEntities.Children)
{
if (lObjEntity.SchemaClassName == "IIsWebServer" || lObjEntity.SchemaClassName == "IIsWebVirtualDir")
{
System.DirectoryServices.PropertyCollection lObjProp = lObjEntity.Properties;
if (lObjProp == null)
continue;
string lStrTemp = "";
lStrTemp = lObjEntity.Name;
if (lStrTemp.Trim() != "")
{
lArLstFinalServices.Add(lStrTemp.Trim());
}
if (lObjEntity.Children != null)
lFnTraceThruChildIISDir(lObjEntity, ref lArLstFinalServices);
}
}
return lArLstFinalServices;
}
catch (Exception)
{
return null;
}
}
void lFnTraceThruChildIISDir(DirectoryEntry aDTEntry, ref ArrayList aArLstServices)
{
try
{
foreach (DirectoryEntry lObjEntity in aDTEntry.Children)
{
if (lObjEntity.SchemaClassName == "IIsWebServer" || lObjEntity.SchemaClassName == "IIsWebVirtualDir")
{
System.DirectoryServices.PropertyCollection lObjProp = lObjEntity.Properties;
if (lObjProp == null)
continue;
string lStrTemp = "";
lStrTemp = lObjEntity.Name;
if (lStrTemp.Trim() != "")
{
aArLstServices.Add(lStrTemp.Trim());
}
if (lObjEntity.Children != null)
lFnTraceThruChildIISDir(lObjEntity, ref aArLstServices);
}
}
}
catch (Exception)
{
}
}
Suthish NairPosted Jun 30, 2011, 1:58 AM