如何在IIS上部署所有网站和Web服务 [英] How to get all the Web sites and Web services deployed on IIS

查看:56
本文介绍了如何在IIS上部署所有网站和Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用以下逻辑来获取详细信息.但是我没有获得站点和服务的实际名称.我应该使用什么查询代替IIsWebInfo来获取所需的所有详细信息.

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 + "<br/>";
                    }
                    lStrOutPut += "<br/><br/>";
                    
                }
}


请帮忙

推荐答案

HI,
有了这段代码,我就拥有了所有IIS的东西.现在如何在这里过滤所有的Web服务.
ArrayList lFnGetWebServicesForServer(string aStrServer)
{
试试
{
字符串lStrIISPath =";
ArrayList lArLstFinalServices =新的ArrayList();
lStrIISPath = @"IIS://" + aStrServer + @"/W3SVC";
DirectoryEntry lObjIIsEntities =新的DirectoryEntry(lStrIISPath);
foreach(lObjIIsEntities.Children中的DirectoryEntry lObjEntity)
{
如果(lObjEntity.SchemaClassName =="IIsWebServer" || lObjEntity.SchemaClassName =="IIsWebVirtualDir")
{
System.DirectoryServices.PropertyCollection lObjProp = lObjEntity.Properties;
如果(lObjProp == null)
继续;
字符串lStrTemp =";

lStrTemp = lObjEntity.Name;
如果(lStrTemp.Trim()!=")
{
lArLstFinalServices.Add(lStrTemp.Trim());
}

如果(lObjEntity.Children!= null)
lFnTraceThruChildIISDir(lObjEntity,ref lArLstFinalServices);
}
}
返回lArLstFinalServices;
}
catch(Exception)
{
返回null;
}
}
void lFnTraceThruChildIISDir(DirectoryEntry aDTEntry,ref ArrayList aArLstServices)
{
试试
{
foreach(aDTEntry.Children中的DirectoryEntry lObjEntity)
{
如果(lObjEntity.SchemaClassName =="IIsWebServer" || lObjEntity.SchemaClassName =="IIsWebVirtualDir")
{
System.DirectoryServices.PropertyCollection lObjProp = lObjEntity.Properties;
如果(lObjProp == null)
继续;
字符串lStrTemp =";

lStrTemp = lObjEntity.Name;
如果(lStrTemp.Trim()!=")
{
aArLstServices.Add(lStrTemp.Trim());
}
如果(lObjEntity.Children!= null)
lFnTraceThruChildIISDir(lObjEntity,ref aArLstServices);
}
}

}
catch(Exception)
{
}
}

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)
{
}
}


这篇关于如何在IIS上部署所有网站和Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆