日期:2014-05-18  浏览次数:20767 次

如何编程进行IIS的相关设置啊?
如何编程进行IIS的相关设置啊?例如允许匿名访问等等方面的设置,如何建立站点。。。。


------解决方案--------------------
前些天看到的~~

DirectoryEntry tbEntry = WebRoot.Children.Add(virtualDirName, strSchema);

//必须以 '\ '结尾
if(virtualDirPath.EndsWith( "\\ ") == false)
{
virtualDirPath += "\\ ";
}
//设置物理目录
tbEntry.Properties[ "Path "][0] = virtualDirPath;
//是否创建为应用程序
tbEntry.Invoke( "AppCreate ",true);
//允许读取
tbEntry.Properties[ "AccessRead "][0] = true;
//允许写入
tbEntry.Properties[ "AccessWrite "][0] = false;
//脚本资源访问
tbEntry.Properties[ "AccessExecute "][0] = false;
//允许匿名访问
tbEntry.Properties[ "AuthAnonymous "][0] = true;
//允许基本验证
tbEntry.Properties[ "AuthBasic "][0] = true;
//允许WIndows集成验证
tbEntry.Properties[ "AuthNTLM "][0] = true;
//索引此资源
tbEntry.Properties[ "ContentIndexed "][0] = false;
//目录浏览
tbEntry.Properties[ "EnableDirBrowsing "][0] = false;
//脚本可执行
tbEntry.Properties[ "AccessScript "][0] = true;
//设置默认文档
tbEntry.Properties[ "DefaultDoc "][0] = "Default.htm, Default.asp, Default.aspx, index.asp, index.htm.index.html ";
tbEntry.Properties[ "EnableDefaultDoc "][0] = true;
//允许父路径
tbEntry.Properties[ "AspEnableParentPaths "][0] = true;

tbEntry.Properties[ "AppFriendlyName "][0] = virtualDirName;
//应用程序保护
tbEntry.Properties[ "AppIsolated "][0] = 2;
//日志访问
tbEntry.Properties[ "DontLog "][0] = true;
tbEntry.CommitChanges();
==================================================================
博客空间:http://blog.csdn.net/lovingkiss
资源下载:http://download.csdn.net/user/lovingkiss
优惠接单开发,组件控件定制开发,成品源代码批发
联系方式:Q64180940 全天在线
==================================================================
------解决方案--------------------
ref:http://www.cnblogs.com/pw/archive/2006/11/21/567029.html
------解决方案--------------------
Some examples of scripting of IIS using ADSI, WMI from VB and C# including the new
http://blog.crowe.co.nz/archive/2006/07/04/663.aspx
------解决方案--------------------
//假如虚拟目录名为 "Webtest ",先在项目中引用
//System.DirectoryServices.dll,再
using System.DirectoryServices;
protected System.DirectoryServices.DirectoryEntry dirroot;

1、添加新的虚拟目录
DirectoryEntry newVirDir = dirroot.Children.Add( "Webtest ", "IIsWebVirtualDir ");
newVirDir.Invoke( "AppCreate ",true);
newVirDir.CommitChanges();
dirroot.CommitChanges();
2、更改虚拟目录属性
//虚拟目录的属性较常用的有:AccessRead,AccessWrite,AccessExecute,AccessScript,DefaultDoc,EnableDefaultDoc,Path等

DirectoryEntry Dirport = dirroot.Children.Find( "Webtest ", "IIsVirtualDir ");
Dirport .Properties[ "AccessRead "][0] = true;

3、删除虚拟目录
DirectoryEntry Dirport = dirroot.Children.Find( "Webtest ", "IIsVirtualDir ");
Dirport.Invoke( "AppDelete ",true);
dirroot.CommitChanges();
或者:

object[] part = new object[2];