• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

《当老温遭遇C#》之虚拟主机管理系统【附核心实现源码】【另可提供中国各大域名服务端 ...

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

老温点评:上次发布了探针后,我决定把相关的知识也理一下,方便于大家,这个是我四年前的作品,练手作,也花了我很多时间,所以代码比较凌乱!现大网上大多数实现虚拟主机管理系统的都是基于ASP+COM或PHP+COM,而且都是收费,看着想改个地方都被约束着,本文凭借C#之光辉打造强大的虚拟主机平台。将实现FTP,IIS,SQL等动态管理,包括在线解压缩的实现等!您可以利用本文涉及到的知识进行多用户域名绑定,多用户在线提供内容服务,对于博客可以实现独立国际域名绑定服务等等

 

直奔主题:下面几个是核心的几大类码,我就不讲了,一看就懂!我这儿有必要讲一下架构的方式:一客户端(前台网站)+后台服务端(网站)+多被控端(提供服务的机子,如FTP服务器,IIS服务器) 因为你的业务达到上万人的时候必须要用这种架构方式,分离提供服务的服务器!UI和用户逻辑这些都是和平常网站管理一样的,最主要的是提供服务类的公用类库,如下,您可以加以改进!另外域名服务中国主要分为四大家,需要加钱入代理商才能提供域名编程接口,因为涉及到商业秘密,我这儿无法直接提供下载,您有需要可以与我联系,QQ:99748954 MSN:[email protected]

 

系统平台:2003+IIS+SER-U+WINMAIL+MSSQL

 

关于IIS的合法安全独立配置会涉及到应用程序池以及WINDOWS安全设置,本文也正是以这个为出发点,动态对WINDOWS帐户进行动态分配与权限设置,您可以详见WINDOWS2003终极安全配置方案,这样一个站点挂掉不会影响其它站点,一个站点对应不同的帐户,您可以将ASP服务的用一个WIN帐户进行绑定10-20个IIS站点,ASPNET站点我推荐1帐户1站点模式.

 

对于域名的接口服务,无法就是你冲钱加盟代理,然后他给你帐户编程接口,利用该合法帐户进行域名查询,域名续费,域名过户等动态编程接口

 

另外一位本人的好友曾经使用我这些资料已经成功开发并运营虚拟主机商服务,已经运营快近一年时间,这个利润还是可以的.我呢也就拿它一包中华抽抽嘻嘻

 

 

 

using System;
using System.DirectoryServices;
using System.Collections;
using System.Text.RegularExpressions;
using System.Text;
using System.Reflection;
using System.IO;
using System.Security.AccessControl;
using Microsoft.Win32;
using System.Diagnostics;
namespace DvCMS.vHost.client
{
    public class IISAdminLib
    {
        #region UserName,Password,HostName的定义

        public static string HostName
        {
            get
            {
                return hostName;
            }
            set
            {
                hostName = value;
            }
        }

        public static string UserName
        {
            get
            {
                return userName;
            }
            set
            {
                userName = value;
            }
        }

        public static string Password
        {
            get
            {
                return password;
            }
            set
            {
                if (UserName.Length <= 1)
                {
                    throw new ArgumentException("还没有指定好用户名。请先指定用户名");
                }
                password = value;
            }
        }

        public static void RemoteConfig(string hostName, string userName, string password)
        {
            HostName = hostName;
            UserName = userName;
            Password = password;
        }

        private static string hostName = "localhost";
        private static string userName;
        private static string password;
        #endregion

        public static void AddFileSecurity(string Account,string path)
        {


            DirectoryInfo di = new DirectoryInfo(path);
            DirectorySecurity ds = di.GetAccessControl();
            FileSystemAccessRule ar1 = new FileSystemAccessRule(Account, FileSystemRights.FullControl, AccessControlType.Allow);
            FileSystemAccessRule ar2 = new FileSystemAccessRule(Account, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow);
            ds.AddAccessRule(ar1);
            ds.AddAccessRule(ar2);
            di.SetAccessControl(ds);
           
        }

        public static void RemoveFileSecurity(string Account, string pathname)
        {
            DirectoryInfo dirinfo = new DirectoryInfo(pathname);

            if ((dirinfo.Attributes & FileAttributes.ReadOnly) != 0)
            {
                dirinfo.Attributes = FileAttributes.Normal;
            }

            //取得访问控制列表
            DirectorySecurity dirsecurity = dirinfo.GetAccessControl();
            dirsecurity.RemoveAccessRuleAll(new FileSystemAccessRule(Account, FileSystemRights.FullControl, AccessControlType.Allow));
            dirinfo.SetAccessControl(dirsecurity);

        }


        //修改NT用户密码
        //传入参数:Username用户名,Userpassword用户新密码
        public static bool InitNTPwd(string Username, string Userpassword)
        {
            try
            {
                DirectoryEntry obComputer = new DirectoryEntry("WinNt://" + Environment.MachineName);
                DirectoryEntry obUser = obComputer.Children.Find(Username, "webaccount");
                obUser.Invoke("SetPassword", Userpassword);
                obUser.CommitChanges();
                obUser.Close();
                obComputer.Close();
                return true;
            }
            catch
            {
                return false;
            }
        }

 


        //删除NT用户
        //传入参数:Username用户名
        public static bool DelNTUser(string strNodeName)
        {
            DirectoryEntry User;
            DirectoryEntry AD=null;
            try
            {
                AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
                User = AD.Children.Find(strNodeName, "User");
                AD.Children.Remove(User);
                return true;
            }
            catch
            {
                return false;
            }
            finally
            {
                AD.Dispose();
              
            }
        }

        /// <summary>
        /// 获取主机头
        /// </summary>
        /// <param name="siteName"></param>
        /// <returns></returns>
        public static string[] GetHeadhost(string siteName)
        {
            ArrayList list = new ArrayList();
            string siteNum = GetWebSiteNum(siteName);
            string siteEntPath = String.Format("IIS://{0}/w3svc/{1}", HostName, siteNum);
            DirectoryEntry siteEntry = GetDirectoryEntry(siteEntPath);
            PropertyValueCollection Thostnames = siteEntry.Properties["ServerBindings"];
            for (int i = 0; i < Thostnames.Count; i++)
            {
                               list.Add(Thostnames[i].ToString());
            }
            if (list.Count == 0)
                return new string[0];
            else
                return (string[])list.ToArray(typeof(string));
          
        }


        public static void CleareHosthead(string siteName)
        {
             string siteNum = GetWebSiteNum(siteName);
            string siteEntPath = String.Format("IIS://{0}/w3svc/{1}", HostName, siteNum);
            DirectoryEntry siteEntry = GetDirectoryEntry(siteEntPath);
            PropertyValueCollection   Thostnames   =  siteEntry.Properties["ServerBindings"];
            Thostnames.Clear();
            siteEntry.CommitChanges();
        }

        public static string RestartIIS()
        {
            string retstr = string.Empty;
            try
            {

                Process.Start("iisreset","stop");
           
            }
            catch (Exception ex)
            {
                retstr = ex.Message;
            }
           return retstr;
           
        }

        /// <summary>
        /// 配置主机头
        /// </summary>
        /// <param name="headhost"></param>
        /// <returns></returns>
        public static void ConfigHeadhost(string siteName, string headhost)
        {
         
            string siteNum = GetWebSiteNum(siteName);
            string siteEntPath = String.Format("IIS://{0}/w3svc/{1}", HostName, siteNum);
            DirectoryEntry siteEntry = GetDirectoryEntry(siteEntPath);
            PropertyValueCollection   Thostnames   =  siteEntry.Properties["ServerBindings"];
            Thostnames.Add(headhost);
            siteEntry.CommitChanges();
                   
        }


        //创建NT用户
        //传入参数:Username要创建的用户名,Userpassword用户密码,Path主文件夹路径
        public static bool CreateNTUser(string Username, string Userpassword, string Path)
        {
            DirectoryEntry obDirEntry = null;
            try
            {
                obDirEntry = new DirectoryEntry("WinNT://" + Environment.MachineName);
                DirectoryEntry obUser = obDirEntry.Children.Add(Username, "User"); //增加用户名
                obUser.Properties["FullName"].Add(Username); //用户全称
                obUser.Invoke("SetPassword", Userpassword); //用户密码
                obUser.Invoke("Put", "Description", "站点相对应的帐号");//用户详细描述
                //obUser.Invoke("Put","PasswordExpired",1); //用户下次登录需更改密码
                obUser.Invoke("Put", "UserFlags", 66049); //密码永不过期
                //obUser.Invoke("Put", "UserFlags", 0x0040);//用户不能更改密码s
                obUser.CommitChanges();//保存用户
                DirectoryEntry grp = obDirEntry.Children.Find("webaccount", "group");//Users组
                if (grp.Name != "")
                {
                    grp.Invoke("Add", obUser.Path.ToString());//将用户添加到某组
                }
                return true;
            }
            catch
            {
                return false;
            }
        }

        //创建IIS_wpg进程用户
        //传入参数:Username要创建的用户名,Userpassword用户密码,Path主文件夹路径
        public static bool CreateAppUser(string Username, string Userpassword, string Path)
        {
            DirectoryEntry obDirEntry = null;
            try
            {
                obDirEntry = new DirectoryEntry("WinNT://" + Environment.MachineName);
                DirectoryEntry obUser = obDirEntry.Children.Add(Username, "User"); //增加用户名
                obUser.Properties["FullName"].Add(Username); //用户全称
                obUser.Invoke("SetPassword", Userpassword); //用户密码
                obUser.Invoke("Put", "Description", "站点相对应的帐号");//用户详细描述
                //obUser.Invoke("Put","PasswordExpired",1); //用户下次登录需更改密码
                obUser.Invoke("Put", "UserFlags", 66049); //密码永不过期
                //obUser.Invoke("Put", "UserFlags", 0x0040);//用户不能更改密码s
                obUser.CommitChanges();//保存用户
                DirectoryEntry grp = obDirEntry.Children.Find("IIS_WPG", "group");//Users组
                if (grp.Name != "")
                {
                    grp.Invoke("Add", obUser.Path.ToString());//将用户添加到某组
                }
                return true;
            }
            catch
            {
                return false;
            }
        }

        /// <summary>
        /// 删除应用程序池
        /// </summary>
        /// <returns></returns>
        public static void DeleteAppPoolByName(string AppPoolName)
        {
          

            try
            {
                DirectoryEntry IISEntryPool = new DirectoryEntry("IIS://localhost/w3svc/AppPools");
                foreach (DirectoryEntry de in IISEntryPool.Children)
                {
                    if (String.Compare(de.Name, AppPoolName, true) == 0)
                    {
                        IISEntryPool.Children.Remove(de);
                        IISEntryPool.CommitChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                //错误处理过程
            }
           
        }

 

        /// <summary>
        /// method是管理应用程序池的方法,有三种Start、Stop、Recycle,而AppPoolName是应用程序池名称
        /// </summary>
        /// <param name="method"></param>
        /// <param name="AppPoolName"></param>
        public 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();
        }
        /// <summary>
        /// 创建一个新的应用程序池
        /// </summary>
        /// <param name="AppPoolName"></param>
        public static void CreateAppPool(string AppPoolName,string WAMUserName,string WAMUserPass)
        {
            DirectoryEntry newpool;
            DirectoryEntry apppools = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
            newpool = apppools.Children.Add(AppPoolName, "IIsApplicationPool");
            newpool.Properties["AppPoolIdentityType"][0] = 0x00000003;
            newpool.Properties["WAMUserName"][0] = WAMUserName;
            newpool.Properties["WAMUserPass"][0] = WAMUserPass;
            newpool.CommitChanges();
        }

 


        /**/
        /// <summary>
        /// 创建站点
        /// </summary>
        /// <param name="iisServer"></param>
        public static void CreateIISWebServer(NewWebSiteInfo siteInfo, string iisp, string iisc, string maxweight, bool ishtml, bool isaspnet, bool asp, bool php, int sessiontimeout)
        {
            if (siteInfo.CommentOfWebSite.ToString() == "")
                throw (new Exception("IISWebServer的ServerComment不能为空!"));
            DirectoryEntry Service = new DirectoryEntry("IIS://" + Environment.MachineName + "/W3SVC");
            DirectoryEntry Server;
            int i = 0;
            IEnumerator ie = Service.Children.GetEnumerator();

            while (ie.MoveNext())
            {
                Server = (DirectoryEntry)ie.Current;
                if (Server.SchemaClassName == "IIsWebServer")
                {
                    if (Convert.ToInt32(Server.Name) > i)
                        i = Convert.ToInt32(Server.Name);
                    //                    if( Server.Properties["Serverbindings"][0].ToString() == ":" + iisServer.Port + ":" )   
                    //                    {
                    //                        Server.Invoke("stop",new object[0]);
                    //                    }
                }
            }
            i++;
            try
            {
               // iisServer.index = i;
                Server = Service.Children.Add(i.ToString(), "IIsWebServer");
                Server.Properties["ServerComment"][0] = siteInfo.CommentOfWebSite;
                Server.Properties["Serverbindings"].Add(siteInfo.BindString);
                Server.Properties["AccessScript"][0] = false;
                Server.Properties["AccessRead"][0] = true;
                Server.Properties["EnableDirBrowsing"][0] = false;
                Server.Properties["LogFileDirectory"].Value = siteInfo.WebPath.Replace("wwwroots", "Logfiles");
                Server.Properties["MaxBandwidth"].Value = Convert.ToInt32(maxweight) * 1024;
                Server.Properties["MaxConnections"].Value = Convert.ToInt32(iisc);
                Server.Properties["DefaultDoc"][0] = "index.htm,Default.htm,index.asp,Default.asp,index.aspx,Default.aspx,index.php,default.php";
                Server.Properties["EnableDefaultDoc"][0] = true;
                Server.Properties["AspEnableParentPaths"].Value = true;
                Server.Properties["AspRequestQueueMax"].Value = iisp;
                Server.Properties["AspSessionTimeout"].Value = sessiontimeout;
                Server.Properties["AppPoolId"].Value = siteInfo.CommentOfWebSite;
                Server.Properties["AnonymousUserName"].Value = siteInfo.CommentOfWebSite;
                Server.Properties["AnonymousUserPass"].Value = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(siteInfo.CommentOfWebSite + "wenweifeng", "md5");
                if (php == false && asp == false && isaspnet == false)
                {

                    Server.Properties["AccessScript"][0] = false;//纯脚本

                }
                else
                {

                    Server.Properties["AccessScript"][0] = true;//纯脚本
                    //继续判断是否支持PHP,ASP,和ASP.Net
                    if (php & asp & isaspnet)
                    {
                        //三种都支持的情况下
                        Server.Properties["ScriptMaps"].Value = GetScriptRun(1);
                    }
                    else if (php & asp & (!isaspnet))
                    {
                        //只支持ASP与PHP的情况下
                        Server.Properties["ScriptMaps"].Value = GetScriptRun(4);
                    }
                    else if ((!php) & asp & isaspnet)
                    {
                        //只支持ASP与Asp.NET的情况下
                        Server.Properties["ScriptMaps"].Value = GetScriptRun(3);
                    }

                    else if ((!php) & asp & (!isaspnet))
                    {
                        //只支持ASP的情况下
                        Server.Properties["ScriptMaps"].Value = GetScriptRun(2);
                    }
                    else
                    {
                        //只支持ASP
                        Server.Properties["ScriptMaps"].Value = GetScriptRun(2);
                    }

                }
                DirectoryEntry root = Server.Children.Add("Root", "IIsWebVirtualDir");
                root.Properties["path"][0] = siteInfo.WebPath;
                //root.Properties["AppIsolated"].Value = 2;

                Service.CommitChanges();
                Server.CommitChanges();
                root.CommitChanges();
                root.Invoke("AppCreate2", new object[1] {2});
                //Server.Invoke("start",new object[0]);
            }
            catch (Exception es)
            {
                throw (es);
            }
        }


       

 

 


        #region 根据路径构造Entry的方法

        /// <summary>
        /// 根据是否有用户名来判断是否是远程服务器。
        /// 然后再构造出不同的DirectoryEntry出来
        /// </summary>
        /// <param name="entPath">DirectoryEntry的路径</param>
        /// <returns>返回的是DirectoryEntry实例</returns>

        public static DirectoryEntry GetDirectoryEntry(string entPath)
        {
            DirectoryEntry ent;
            if (UserName == null)
            {
                ent = new DirectoryEntry(entPath);
            }
            else
            {
                // ent = new DirectoryEntry(entPath, HostName+"\"+UserName, Password, AuthenticationTypes.Secure);
                ent = new DirectoryEntry(entPath, UserName, Password, AuthenticationTypes.Secure);
            }
            return ent;
        }

        #endregion
        #region 添加,删除网站的方法

        /// <summary>
        /// 创建一个新的网站。根据传过来的信息进行配置
        /// </summary>
        /// <param name="siteInfo">存储的是新网站的信息</param>

        public static void CreateNewWebSite(NewWebSiteInfo siteInfo, string iisp, string iisc, string maxweight, bool ishtml, bool isaspnet, bool asp, bool php,int sessiontimeout)
        {
            if (!EnsureNewSiteEnavaible(siteInfo.BindString))
            {
                //throw new DuplicatedWebSiteException("已经有了这样的网站了。" + Environment.NewLine + siteInfo.BindString);
            }
            else
            {
                string entPath = String.Format("IIS://{0}/w3svc", HostName);
                DirectoryEntry rootEntry = GetDirectoryEntry(entPath);
                string newSiteNum = GetNewWebSiteID();
                DirectoryEntry newSiteEntry = rootEntry.Children.Add(newSiteNum, "IIsWebServer");
                newSiteEntry.CommitChanges();
                newSiteEntry.Properties["ServerBindings"].Value = siteInfo.BindString;
                newSiteEntry.Properties["ServerComment"][0] = siteInfo.CommentOfWebSite;
                //应用程序部分
                newSiteEntry.Properties["KeyType"].Value = "IIsWebServer";
                //判断为HTML主机则将应用FALSE,判断依据为ASP,PHP,ASPNET都为False
                newSiteEntry.Properties["AccessRead"][0] = true;//读
                newSiteEntry.Properties["AccessExecute"][0] = false;
                if (php == false && asp == false && isaspnet == false)
                {

                    newSiteEntry.Properties["AccessScript"][0] = false;//纯脚本

                }
                else
                {

                    newSiteEntry.Properties["AccessScript"][0] = true;//纯脚本
                    //继续判断是否支持PHP,ASP,和ASP.Net
                    if (php & asp & isaspnet)
                    {
                        //三种都支持的情况下
                        newSiteEntry.Properties["ScriptMaps"].Value = GetScriptRunver2(1);
                    }
                    else if (php & asp & (!isaspnet))
                    {
                        //只支持ASP与PHP的情况下
                        newSiteEntry.Properties["ScriptMaps"].Value = GetScriptRunver2(4);
                    }
                    else if ((!php) & asp & isaspnet)
                    {
                        //只支持ASP与Asp.NET的情况下
                        newSiteEntry.Properties["ScriptMaps"].Value = GetScriptRunver2(3);
                    }

                    else if ((!php) & asp & (!isaspnet))
                    {
                        //只支持ASP的情况下
                        newSiteEntry.Properties["ScriptMaps"].Value = GetScriptRunver2(2);
                    }
                    else
                    {
                        //只支持ASP
                        newSiteEntry.Properties["ScriptMaps"].Value = GetScriptRunver2(2);
                    }

                }
               
               //newSiteEntry.Properties["AppIsolated"].Value = 2;
                //站点的日志文件
               newSiteEntry.Properties["LogFileDirectory"].Value = siteInfo.WebPath.Replace("wwwroots", "Logfiles");
                //站点的最大带宽
                newSiteEntry.Properties["MaxBandwidth"].Value = Convert.ToInt32(maxweight)*1024;
                //站点的最大连接客户数
               newSiteEntry.Properties["MaxConnections"].Value =Convert.ToInt32(iisc);
                newSiteEntry.CommitChanges();
                DirectoryEntry vdEntry = newSiteEntry.Children.Add("root", "IIsWebVirtualDir");
               // vdEntry.Invoke("AppCreate2", 2);
               vdEntry.Properties["AppRoot"].Value = "LM/W3SVC/" + newSiteNum + "/Root";
               vdEntry.Properties["Path"][0] = siteInfo.WebPath;
               vdEntry.Properties["EnableDefaultDoc"][0] = false;
               vdEntry.Properties["AppFriendlyName"].Value = "默认应用程序";
              vdEntry.Properties["AppPoolId"].Value = siteInfo.CommentOfWebSite;
                vdEntry.Properties["AnonymousUserName"].Value = siteInfo.CommentOfWebSite;
               vdEntry.Properties["AnonymousUserPass"].Value = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(siteInfo.CommentOfWebSite + "wenweifeng", "md5");
               vdEntry.Properties["DefaultDoc"][0] = "index.htm,Default.htm,index.asp,Default.asp,index.aspx,Default.aspx,index.php,default.php";
               //vdEntry.Properties["DefaultDocFooter"].Value = false;//有严重的问题导致数据无效
              vdEntry.Properties["EnableDefaultDoc"][0] = true;
              vdEntry.Properties["EnableDirBrowsing"][0] = false;//目录浏览
              vdEntry.Properties["AccessWrite"][0] = false;//写入
               // vdEntry.Properties["AppAllowClientDebug"].Value = true;
                vdEntry.Properties["AspEnableParentPaths"].Value = true;
               // vdEntry.Properties["AspAllowSessionState"].Value = true;
                  //ASP应用程序的Sessiontimeout会话时间
                //vdEntry.Properties["AspSessionTimeout"].Value = sessiontimeout;
                vdEntry.Properties["AspScriptLanguage"].Value = "VBScript";
                //vdEntry.Properties["AspScriptTimeout"].Value = 90;
                //  ASP最大查询并发数
                vdEntry.Properties["AspRequestQueueMax"].Value = iisp;
               // vdEntry.Properties["AspScriptErrorSentToBrowser"].Value = false;
                //Type typ = vdEntry.Properties["IPSecurity"][0].GetType();
                //object IPSecurity = vdEntry.Properties["IPSecurity"][0];
                //object[] newIPDenyList = new object[4];
                //newIPDenyList[0] = "192.168.1.1,   255.255.255.255";
                //newIPDenyList[1] = "192.168.1.2,   255.255.255.255";
                //newIPDenyList[2] = "192.168.1.3,   255.255.255.255";
                //newIPDenyList[3] = "192.168.1.4,   255.255.255.255";

                //typ.InvokeMember("IPDeny",
                //                               BindingFlags.DeclaredOnly |
                //                               BindingFlags.Public | BindingFlags.NonPublic |
                //                               BindingFlags.Instance | BindingFlags.SetProperty,
                //                               null, IPSecurity, new object[] { newIPDenyList });

                //vdEntry.Properties["IPSecurity"][0] = IPSecurity;
               vdEntry.Invoke("AppCreate2", new object[1] { 2 });
                vdEntry.CommitChanges();
                rootEntry.CommitChanges();
            }
        }


        public static string[] GetScriptRunver2(int i)
        {
            string[] _script1;
            string[] _script2;
            string[] _script3;
            string[] _script4;
            string[] ret;
            //支持 asp/asp.net/php
            _script1 = new string[27]{".asa,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
   ".asax,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".ascx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".ashx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
   ".asmx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
   ".asp,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
   ".aspx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
   ".axd,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
   ".cdx,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
   ".cer,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
   ".config,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".cs,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".csproj,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".idc,"+@"c:\windows"+@"\system32\inetsrv\httpodbc.dll,5,GET,POST",
   ".licx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
    ".php,"+"\"D:\\Program Files\\PHP\\php5isapi.dll\",5",
   ".rem,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
   ".resources,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".resx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".shtm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
   ".shtml,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
   ".soap,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
   ".stm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
   ".vb,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".vbproj,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".vsdisco,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
   ".webinfo,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
         };
            //支持 asp
            _script2 = new string[8]{".asa,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
                                     ".asp,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
          ".cdx,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
          ".cer,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
          ".idc,"+@"c:\windows"+@"\system32\inetsrv\httpodbc.dll,5,GET,POST",
          ".shtm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
          ".shtml,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
          ".stm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST"
           };
            //支持 asp/asp.net
            _script3 = new string[26]{".asa,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
           ".asax,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".ascx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".ashx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
           ".asmx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
           ".asp,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
           ".aspx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
           ".axd,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
           ".cdx,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
           ".cer,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
           ".config,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".cs,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".csproj,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".idc,"+@"c:\windows"+@"\system32\inetsrv\httpodbc.dll,5,GET,POST",
           ".licx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           //".php,"+@"c:\windows"+@"\system32\php5isapi.dll,5",
           ".rem,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
           ".resources,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".resx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".shtm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
           ".shtml,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
           ".soap,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
           ".stm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
           ".vb,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".vbproj,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".vsdisco,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
           ".webinfo,"+@"c:\windows"+@"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG"
   };
            //支持 asp/php
            _script4 = new string[9]{".asa,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
          ".asp,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
          ".cdx,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
          ".cer,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
          ".idc,"+@"c:\windows"+@"\system32\inetsrv\httpodbc.dll,5,GET,POST",
           ".php,"+"\"D:\\Program Files\\PHP\\php5isapi.dll\",5",
          ".shtm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
          ".shtml,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
          ".stm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST"
         };


            if (i == 1)
            {
                ret = _script1;
            }
            else if (i == 2)
            {
                ret = _script2;
            }
            else if (i == 3)
            {
                ret = _script3;
            }
            else
            {
                ret = _script4;
            }
            return ret;
        }


   
public static string[] GetScriptRun(int i)
   {
  string [] _script1;
  string [] _script2;
  string [] _script3;
  string [] _script4;
  string[] ret;
  //支持 asp/asp.net/php
  _script1 = new string[27]{".asa,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
   ".asax,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".ascx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".ashx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
   ".asmx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
   ".asp,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
   ".aspx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
   ".axd,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
   ".cdx,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
   ".cer,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
   ".config,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".cs,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".csproj,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".idc,"+@"c:\windows"+@"\system32\inetsrv\httpodbc.dll,5,GET,POST",
   ".licx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
    ".php,"+"\"D:\\Program Files\\PHP\\php5isapi.dll\",5",
   ".rem,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
   ".resources,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".resx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".shtm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
   ".shtml,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
   ".soap,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
   ".stm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
   ".vb,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".vbproj,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
   ".vsdisco,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
   ".webinfo,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
         };
  //支持 asp
  _script2 = new string[8]{".asa,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
                                     ".asp,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
          ".cdx,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
          ".cer,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
          ".idc,"+@"c:\windows"+@"\system32\inetsrv\httpodbc.dll,5,GET,POST",
          ".shtm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
          ".shtml,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
          ".stm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST"
           };
  //支持 asp/asp.net
  _script3 = new string[26]{".asa,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
           ".asax,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".ascx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".ashx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
           ".asmx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
           ".asp,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
           ".aspx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
           ".axd,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
           ".cdx,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
           ".cer,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
           ".config,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".cs,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".csproj,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".idc,"+@"c:\windows"+@"\system32\inetsrv\httpodbc.dll,5,GET,POST",
           ".licx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           //".php,"+@"c:\windows"+@"\system32\php5isapi.dll,5",
           ".rem,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
           ".resources,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".resx,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".shtm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
           ".shtml,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
           ".soap,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
           ".stm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
           ".vb,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".vbproj,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG",
           ".vsdisco,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG",
           ".webinfo,"+@"c:\windows"+@"\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG"
   };
  //支持 asp/php
      _script4 = new string[9]{".asa,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
          ".asp,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
          ".cdx,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
          ".cer,"+@"c:\windows"+@"\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE",
          ".idc,"+@"c:\windows"+@"\system32\inetsrv\httpodbc.dll,5,GET,POST",
           ".php,"+"\"D:\\Program Files\\PHP\\php5isapi.dll\",5",
          ".shtm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
          ".shtml,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST",
          ".stm,"+@"c:\windows"+@"\system32\inetsrv\ssinc.dll,5,GET,POST"
         };

     
      if (i == 1)
      {
          ret = _script1;
      }
      else if (i == 2)
      {
          ret = _script2;
      }
      else if (i == 3)
      {
          ret = _script3;
      }
      else
      {
          ret = _script4;
      }
      return ret;
        }


        /// <summary>
        /// 获取网站绑定的目录
        /// </summary>
        /// <param name="siteName"></param>
        /// <returns></returns>
        public static string GetWebPath(string siteName)
        {
            string siteNum = GetWebSiteNum(siteName);
            string siteEntPath = String.Format("IIS://{0}/w3svc/{1}", HostName, siteNum);
            DirectoryEntry siteEntry = GetDirectoryEntry(siteEntPath);
            DirectoryEntry vdEntry = siteEntry.Children.Find("root", "IIsWebVirtualDir");
            return vdEntry.Properties["Path"].Value.ToString();
        }

        /// <summary>
        /// 获取网站文件头文档
        /// </summary>
        /// <param name="siteName"></param>
        /// <returns></returns>
        public static string GetDefautdoclist(string siteName)
        {
            string siteNum = GetWebSiteNum(siteName);
            string siteEntPath = String.Format("IIS://{0}/w3svc/{1}", HostName, siteNum);
            DirectoryEntry siteEntry = GetDirectoryEntry(siteEntPath);
            DirectoryEntry vdEntry = siteEntry.Children.Find("root", "IIsWebVirtualDir");
            return vdEntry.Properties["DefaultDoc"].Value.ToString();
        }

        /// <summary>
        /// 设置网站文件头文档
        /// </summary>
        /// <param name="siteName"></param>
        /// <param name="defdoc"></param>
        /// <returns></returns>
        public static void SetDefautdoclist(string siteName, string defdoc)
        {
            string siteNum = GetWebSiteNum(siteName);
            string siteEntPath = String.Format("IIS://{0}/w3svc/{1}", HostName, siteNum);
            DirectoryEntry siteEntry = GetDirectoryEntry(siteEntPath);
            DirectoryEntry vdEntry = siteEntry.Children.Find("root", "IIsWebVirtualDir");
            vdEntry.Properties["DefaultDoc"].Value = defdoc;
            vdEntry.CommitChanges();
            siteEntry.CommitChanges();
        }

        public static string GetASPNETVERSION(string siteName)
        {
         
            string Version = "1.1";
            string siteNum = GetWebSiteNum(siteName);
            string siteEntPath = String.Format("IIS://{0}/w3svc/{1}", HostName, siteNum);
            DirectoryEntry newSiteEntry = GetDirectoryEntry(siteEntPath);
            if (newSiteEntry.Properties["ScriptMaps"][1].ToString().IndexOf("v2.0")>0)
            {
                Version = "2.0";
            }
        
            //PropertyValueCollection valueCollection = newSiteEntry.Properties["ScriptMaps"];
            //for (int i = 0; i < valueCollection.Count; i++)
            //{
            //    Version += ("[" + i.ToString() + "] =" + valueCollection[i].ToString() + "                                                 ");
            //}
            return Version;

        }


        /// <summary>
        /// 设置ASP.net 的版本
        /// </summary>
        /// <param name="siteName"></param>
        /// <param name="version"></param>
        public static void SetASPNETVERSION(string siteName,string  version,bool asp,bool php,bool isaspnet)
        {
            string siteNum = GetWebSiteNum(siteName);
            string siteEntPath = String.Format("IIS://{0}/w3svc/{1}", HostName, siteNum);
            DirectoryEntry newSiteEntry = GetDirectoryEntry(siteEntPath);
            newSiteEntry.Properties["ScriptMaps"].Clear();
            if (version == "1.1")
            {
                if (php & asp & isaspnet)
                {
                    //三种都支持的情况下
                    newSiteEntry.Properties["ScriptMaps"].Value = GetScriptRun(1);
                }
                else if (php & asp & (!isaspnet))
                {
                    //只支持ASP与PHP的情况下
                    newSiteEntry.Properties["ScriptMaps"].Value = GetScriptRun(4);
                }
                else if ((!php) & asp & isaspnet)
                {
                    //只支持ASP与Asp.NET的情况下
                    newSiteEntry.Properties["ScriptMaps"].Value = GetScriptRun(3);
                }

                else if ((!php) & asp & (!isaspnet))
                {
                    //只支持ASP的情况下
                    newSiteEntry.Properties["ScriptMaps"].Value = GetScriptRun(2);
                }
                else
                {
                    //只支持ASP
                    newSiteEntry.Properties["ScriptMaps"].Value = GetScriptRun(2);
                }
            }
            else
            {
                //asp.net 2.0
                if (php & asp & isaspnet)
                {
                    //三种都支持的情况下
                    newSiteEntry.Properties["ScriptMaps"].Value = GetScriptRunver2(1);
                }
                else if (php & asp & (!isaspnet))
                {
                    //只支持ASP与PHP的情况下
                    newSiteEntry.Properties["ScriptMaps"].Value = GetScriptRunver2(4);
                }
                else if ((!php) & asp & isaspnet)
                {
                    //只支持ASP与Asp.NET的情况下
                    newSiteEntry.Properties["ScriptMaps"].Value = GetScriptRunver2(3);
                }

                else if ((!php) & asp & (!isaspnet))
                {
                    //只支持ASP的情况下
                    newSiteEntry.Properties["ScriptMaps"].Value = GetScriptRunver2(2);
                }
                else
                {
                    //只支持ASP
                    newSiteEntry.Properties["ScriptMaps"].Value = GetScriptRunver2(2);
                }
            }

            newSiteEntry.CommitChanges();
        }


        /// <summary>
        /// 获取ASP脚本自定义错误到游览器
        /// </summary>
        /// <param name="siteName"></param>
        /// <returns></returns>
        public static string AspScriptErrorSentToBrowser(string siteName)
        {
            string siteNum = GetWebSiteNum(siteName);
            string siteEntPath = String.Format("IIS://{0}/w3svc/{1}", HostName, siteNum);
            DirectoryEntry siteEntry = GetDirectoryEntry(siteEntPath);
            DirectoryEntry vdEntry = siteEntry.Children.Find("root", "IIsWebVirtualDir");
            return vdEntry.Properties["AspScriptErrorSentToBrowser"].Value.ToString() + "|" + vdEntry.Properties["AspScriptErrorMessage"].Value.ToString();
        }

        public static void SetAspScriptErrorSentToBrowser(string siteName, string Message, bool configbool)
        {
            string siteNum = GetWebSiteNum(siteName);
            string siteEntPath = String.Format("IIS://{0}/w3svc/{1}", HostName, siteNum);
            DirectoryEntry siteEntry = GetDirectoryEntry(siteEntPath);
            DirectoryEntry vdEntry = siteEntry.Children.Find("root", "IIsWebVirtualDir");
            vdEntry.Properties["AspScriptErrorSentToBrowser"].Value = configbool;
            vdEntry.Properties["AspScriptErrorMessage"].Value = Message;
            vdEntry.CommitChanges();
            siteEntry.CommitChanges();

        }

        public static string[] GetWebinfo(string siteName)
        {
            ArrayList list = new ArrayList();
            string siteNum = GetWebSiteNum(siteName);
            string siteEntPath = String.Format("IIS://{0}/w3svc/{1}", HostName, siteNum);
            DirectoryEntry siteEntry = GetDirectoryEntry(siteEntPath);
            //list.Add(siteEntry.SchemaClassName.ToString());
            list.Add("绑定信息" + "       " + siteEntry.Properties["ServerBindings"].Value.ToString());
            list.Add("站点注释" + "       " + siteEntry.Properties["ServerComment"].Value.ToString());
            list.Add("节点类型" + "$" + siteEntry.Properties["KeyType"].Value.ToString());
            list.Add("读取" + "$" + siteEntry.Properties["AccessRead"][0].ToString());
            list.Add("纯脚本" + "$" + siteEntry.Properties["AccessScript"][0].ToString());
            list.Add("任意文件执行" + "$" + siteEntry.Properties["AccessExecute"][0].ToString());
            list.Add("进程运行" + "$" + siteEntry.Properties["AppIsolated"].Value.ToString());
            list.Add("日志目录" + "$" + siteEntry.Properties["LogFileDirectory"].Value.To


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#读写Image发布时间:2022-07-10
下一篇:
C#裁剪图片发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap