Пример #1
0
        public void CreateNewVirtualDirectory(int ServerId, string VirtualDirName, string Path, bool AccessScript)
        {
            DirectoryEntry Parent = new DirectoryEntry(@"IIS://localhost/W3SVC/" + ServerId.ToString() + "/Root");
            DirectoryEntry NewVirtualDir;

            NewVirtualDir = Parent.Children.Add(VirtualDirName, "IIsWebVirtualDir");
            NewVirtualDir.Properties["Path"][0]         = Path;
            NewVirtualDir.Properties["AccessScript"][0] = AccessScript.ToString();
            // NewVirtualDir.Properties["AppFriendlyName"][0] = VirtualDirName;
            NewVirtualDir.CommitChanges();
            NewVirtualDir.Invoke("AppCreate", 1);
        }
Пример #2
0
        public static void CreateIisVirtualDirectory(string VdName, string AppPoolName, string Path)
        {
            try
            {
                DirectoryEntry Parent = new DirectoryEntry(@"IIS://localhost/W3SVC/1/Root");
                DirectoryEntry NewVirtualDir;
                NewVirtualDir = Parent.Children.Add(VdName, "IIsWebVirtualDir");
                NewVirtualDir.Properties["Path"][0]            = Path;
                NewVirtualDir.Properties["AuthFlags"][0]       = 5;
                NewVirtualDir.Properties["AppFriendlyName"][0] = VdName;
                try
                {
                    NewVirtualDir.Properties["AppPoolId"][0] = AppPoolName;
                }
                catch { }
                NewVirtualDir.Properties["AccessFlags"][0] = 517;
                NewVirtualDir.Properties["AppRoot"][0]     = "/LM/W3SVC/1/Root/" + VdName;

                NewVirtualDir.CommitChanges();
            }
            catch { }
        }