Пример #1
0
        // Delete an application pool from IIS
        public static void DeleteApplicationPool(string domain, string username, string password, string appPoolName)
        {
            DirectoryEntry root = DirectoryEntryTool.GetRoot(DirectoryEntryRootType.AppPool, domain, username, password);

            root.Invoke("Delete", "IIsApplicationPool", appPoolName);
            root.CommitChanges();
        }
Пример #2
0
        // Delete a virtual directory
        public static void DeleteVirtualDirectory(string domain, string username, string password, string name)
        {
            DirectoryEntry root = DirectoryEntryTool.GetRoot(DirectoryEntryRootType.IIS, domain, username, password);
            DirectoryEntry vDir = DirectoryEntryTool.GetVirtualDirectory(domain, root, name);

            root.Children.Remove(vDir);
            root.CommitChanges();
        }
Пример #3
0
        // Create a virtual directory
        public static void CreateVirtualDirectory(string domain, string username, string password, string name, string path, string appPoolName)
        {
            DirectoryEntry root = DirectoryEntryTool.GetRoot(DirectoryEntryRootType.IIS, domain, username, password);
            DirectoryEntry vDir = DirectoryEntryTool.GetVirtualDirectory(domain, root, name);

            root.CommitChanges();
            vDir.CommitChanges();

            SaveProperties(vDir, name, path, appPoolName);
        }
Пример #4
0
        // Get the names of all the virtual directories in IIS
        public static string[] GetVirtualDirectories(string domain, string username, string password)
        {
            List <string> vDirs = new List <string>();

            DirectoryEntry root = DirectoryEntryTool.GetRoot(DirectoryEntryRootType.IIS, domain, username, password);

            foreach (DirectoryEntry vDir in root.Children)
            {
                vDirs.Add(vDir.Name);
            }

            return(vDirs.ToArray());
        }
Пример #5
0
        // Get the names of all the application pools in IIS
        public static string[] GetApplicationPools(string domain, string username, string password)
        {
            DirectoryEntry root = DirectoryEntryTool.GetRoot(DirectoryEntryRootType.AppPool, domain, username, password);

            List <string> appPools = new List <string>();

            foreach (DirectoryEntry entry in root.Children)
            {
                appPools.Add(entry.Name);
            }

            return(appPools.ToArray());
        }
Пример #6
0
        // Create a new application pool in IIS
        public static void CreateApplicationPool(string domain, string username, string password, string appPoolName, bool enable32BitAppOnWin64, string dotnetRuntimeVersion)
        {
            DirectoryEntry root    = DirectoryEntryTool.GetRoot(DirectoryEntryRootType.AppPool, domain, username, password);
            DirectoryEntry appPool = root.Invoke("Create", "IIsApplicationPool", appPoolName) as DirectoryEntry;

            if (appPool != null)
            {
                if (Globals.IISMajorVersionNumber > 6)
                {
                    if (enable32BitAppOnWin64)
                    {
                        appPool.Properties["Enable32BitAppOnWin64"].Value = true;
                    }
                    else
                    {
                        appPool.Properties["Enable32BitAppOnWin64"].Value = false;
                    }
                }

                if (Globals.IISMajorVersionNumber >= 7)
                {
                    appPool.Properties["ManagedRuntimeVersion"].Value = dotnetRuntimeVersion;
                    appPool.Properties["ManagedPipelineMode"].Value   = 0; // Integrated
                }

                // Change the identity to LocalSystem, possible values:
                // 0  Local System
                // 1  Local Service
                // 2  Network Service
                // 3  Specific user
                appPool.InvokeSet("AppPoolIdentityType", new Object[] { 0 });

                appPool.CommitChanges();
            }
            root.CommitChanges();
        }