您的位置:程序门 -> .net技术 -> c#



如何编程进行iis的相关设置啊?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


如何编程进行iis的相关设置啊?[已结贴,结贴人:quickregion]
发表于:2007-08-16 09:12:35 楼主
如何编程进行iis的相关设置啊?例如允许匿名访问等等方面的设置,如何建立站点。。。。
发表于:2007-08-16 09:16:431楼 得分:50
前些天看到的~~

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   全天在线
==================================================================
发表于:2007-08-16 09:17:042楼 得分:10
ref:http://www.cnblogs.com/pw/archive/2006/11/21/567029.html
发表于:2007-08-16 09:21:183楼 得分:10
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
发表于:2007-08-16 09:22:334楼 得分:0
ls
发表于:2007-08-16 09:24:515楼 得分:30
//假如虚拟目录名为 "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];
          part[0]   =   "iiswebvirtualdir ";  
          part[1]   =   "webtest ";
          dirroot.invoke( "delete ",part);
          dirroot.commitchanges();


快速检索

最新资讯
热门点击