Пример #1
0
        /// <summary>
        /// Delete an app pool
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static bool DeleteAppPool(string name)
        {
            if (IISAppPool.Exsit(name) == false)
            {
                return(false);
            }

            IISAppPool appPool = IISAppPool.OpenAppPool(name);

            appPool._entry.DeleteTree();
            return(true);
        }
Пример #2
0
        /// <summary>
        /// Open a application pool and return an IISAppPool instance
        /// </summary>
        /// <param name="name">application pool name</param>
        /// <returns>IISAppPool object</returns>
        public static IISAppPool OpenAppPool(string name)
        {
            string connectStr = "IIS://localhost/W3SVC/AppPools/";

            connectStr += name;

            if (IISAppPool.Exsit(name) == false)
            {
                return(null);
            }


            DirectoryEntry entry = new DirectoryEntry(connectStr);

            return(new IISAppPool(entry));
        }
Пример #3
0
        /// <summary>
        /// create app pool
        /// </summary>
        /// <param name="name">the app pool to be created</param>
        /// <returns>IISAppPool created if success, else null</returns>
        public static IISAppPool CreateAppPool(string name)
        {
            DirectoryEntry Service = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");

            foreach (DirectoryEntry entry in Service.Children)
            {
                if (entry.Name.Trim().ToLower() == name.Trim().ToLower())
                {
                    return(IISAppPool.OpenAppPool(name.Trim()));
                }
            }

            // create new app pool
            DirectoryEntry appPool = Service.Children.Add(name, "IIsApplicationPool");

            appPool.CommitChanges();
            Service.CommitChanges();

            return(new IISAppPool(appPool));
        }
Пример #4
0
        /// <summary>
        /// create application from this dir
        /// </summary>
        /// <param name="appPool">app pool to use, null means default</param>
        public void CreateApplication(IISAppPool appPool)
        {
            if (appPool == null)
            {
                this.server.Invoke("AppCreate", true);
            }
            else
            {
                this.server.Invoke("AppCreate3", new object[] { 0, appPool.Name, true });
            }

            this.server.Properties["AppFriendlyName"].Clear();
            this.server.Properties["AppIsolated"].Clear();
            this.server.Properties["AccessFlags"].Clear();
            this.server.Properties["FrontPageWeb"].Clear();
            this.server.Properties["AppFriendlyName"].Add(this.server.Name);
            this.server.Properties["AppIsolated"].Add(2);
            this.server.Properties["AccessFlags"].Add(513);
            this.server.Properties["FrontPageWeb"].Add(1);
            //siteVDir.Invoke("AppCreate3",   new   object[]   {2,   "DefaultAppPool",   true});

            this.server.CommitChanges();
        }