- 热门文章:
- · ASP.NET虚拟主机安全漏洞解决方案(4)
- · 利用ASP.NET 2.0创建自定义Web控件(1)
- · 利用ASP.NET 2.0创建自定义Web控件(2)
- · 利用ASP.NET 2.0创建自定义Web控件(3)
- · 利用ASP.NET 2.0创建自定义Web控件(4)
- · 利用ASP.NET 2.0创建自定义Web控件(5)
- · 在ASP.NET下实现数字和字符相混合的验证码
- · 生成图象验证码函数
- · 在ASP.NET 2.0中使用页面导航控件(1)
- · 在ASP.NET 2.0中使用页面导航控件(2)
- · DataGrid基于Access的快速分页法(1)
- · DataGrid基于Access的快速分页法(2)
上一篇:ASP.NET虚拟主机安全漏洞解决方案(2) >>
ASP.NET虚拟主机安全漏洞解决方案(3)
using System;
using System.DirectoryServices;
using System.Reflection;
namespace ADSI1
{
///
/// Small class containing methods to configure IIS.
///
class ConfigIIS
{
///
/// The main entry point for the application.
///
[STAThread]
//主程序入口,可以选择用哪些,我为了方便,全部功能都写上去了。
static void Main(string[] args)
{
string AppPoolName = "MyAppPool";
string newvdir1 = "MyVDir";
DirectoryEntry newvdir = CreateVDir(newvdir1);
CreateAppPool(AppPoolName);
AssignAppPool(newvdir, AppPoolName);
ConfigAppPool("Stop",AppPoolName);
}
//创建虚拟目录
static DirectoryEntry CreateVDir (string vdirname)
{
DirectoryEntry newvdir;
DirectoryEntry root=new DirectoryEntry("IIS://localhost/W3SVC/1/Root");
newvdir=root.Children.Add(vdirname, "IIsWebVirtualDir");
newvdir.Properties["Path"][0]= "c:\\inetpub\\wwwroot";
newvdir.Properties["AccessScript"][0] = true;
newvdir.CommitChanges();
return newvdir;
}
//创建新的应用程序池。
static void CreateAppPool(string AppPoolName)
{
DirectoryEntry newpool;
DirectoryEntry apppools=new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
newpool=apppools.Children.Add(AppPoolName, "IISAPplicationPool");
newpool.CommitChanges();
}
static void AssignAppPool(DirectoryEntry newvdir, string AppPoolName)
{
object[] param={0, AppPoolName, true};
newvdir.Invoke("AppCreate3", param);
}
//method是管理应用程序池的方法,有三种Start、Stop、Recycle,而AppPoolName是应用程序池名称
static void ConfigAppPool(string method,string AppPoolName)
{
DirectoryEntry appPool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
DirectoryEntry findPool = appPool.Children.Find(AppPoolName,IIsApplicationPool");
findPool.Invoke(method,null);
appPool.CommitChanges();
appPool.Close();
}
//应用程序池的列表
static void AppPoolList()
{
DirectoryEntry appPool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
foreach(DirectoryEntry a in appPool.Children)
{
Console.WriteLine(a.Name);
}
}
private void VDirToAppPool()
{
DirectroryEntry VD = new DirectoryEntry("IIS://localhost/W3SVC/1/ROOT/ccc");
Console.WriteLine(VD.Properties["AppPoolId"].Value.ToString());
}
}
}
下一篇:ASP.NET虚拟主机安全漏洞解决方案(4) >>
相关文章:
- · DataGrid基于Access的快速分页法(3)
- · DataGrid基于Access的快速分页法(4)
- · ASP.NET中对表单输入行有选择验证(1)
- · ASP.NET中对表单输入行有选择验证(2)
- · Javascript利用xmlhttp获得服务器时钟的方法
- · 用ASP编写的俄罗斯方块游戏
- · 复选框用法
- · 复选框用法
- · [漏洞]利用Activer server explorer可对文件进行读写访问
- · 给你的FSO对象加把锁
- · ASP有函数可以把某个网页通过STREAM下载吗?
- · 控制输出字符串的长度,可以区别中英文
- · 存储过程编写经验和优化措施
- · ASP.NET入门随想之工业流水线
- · ASP.NET入门随想之抽象的力量
- · ASP.NET入门随想之瘦子与胖子的故事
- · ASP.NET入门随想之开卷有益
- · ASP.NET中随机数生成及应用(2)
- · ASP.NET中随机数生成及应用(1)
- · ASP.NET中实现Flash与.NET的紧密集成(1)
- · ASP.NET中实现Flash与.NET的紧密集成(2)
- · 深度解析ASP.NET2.0中的Callback机制(1)
- · ASP.NET+AJAX解决网页打开等待问题(1)
- · ASP.NET+AJAX解决网页打开等待问题(2)
- · C#中为DataGrid添加下拉列表框
- · ASP.NET开发员工业绩评测中心(1)
- · ASP.NET开发员工业绩评测中心(2)
- · 在ASP应用程序中限制重复提交同一表单
- · 用VB将ASP代码封装成DLL
- · 如何在IIS上搭建WAP网站
- · asp程序错误详细说明例表
- · 短信发送程序
- · 用ASP实现电子贺卡
- · ASP.NET创建并使用Web组件(1)
- · asp.net生成缩略图
- · 动态增加的DropDownList如何保持状态
- · ASP.NET创建并使用Web组件(2)
- · ASP.NET创建并使用Web组件(3)
