public bool WebDeployServiceVirtualDirectoryExists(WebSiteEntry webSite, string virtualDirectoryName) { try { using (DirectoryEntry directoryEntry = new DirectoryEntry(webSite.Path + "/Root/" + virtualDirectoryName + "/DeployWebService")) { if (directoryEntry.SchemaClassName.ToLower().StartsWith("iisweb")) { return(true); } } } catch { } return(false); }
public Models.VirtualDirectory CreateVirtualDirectory (string name, string domain, string installationPath, string defaultDocument, WebSiteEntry website, string applicationPool, bool isNested, bool keepAppPoolAsIs = false) { string str = "IIS://127.0.0.1/W3SVC/1/Root" + (isNested ? string.Empty : "/Root"); using (DirectoryEntry directoryEntry1 = new DirectoryEntry("IIS://127.0.0.1/W3SVC/1/Root")) { directoryEntry1.RefreshCache(); using (DirectoryEntry directoryEntry2 = directoryEntry1.Children.Add(name, "IISWebVirtualDir")) { directoryEntry2.Properties["Path"].Insert(0, (object)installationPath); directoryEntry2.CommitChanges(); directoryEntry1.CommitChanges(); directoryEntry2.Invoke("AppCreate", (object)true); directoryEntry2.Properties["AuthFlags"].Value = (object)1; directoryEntry2.Properties["AppFriendlyName"].Value = (object)name; if (!string.IsNullOrEmpty(defaultDocument)) { directoryEntry2.Properties["DefaultDoc"].Value = (object)"default.aspx"; } directoryEntry2.CommitChanges(); directoryEntry1.CommitChanges(); directoryEntry2.Close(); } directoryEntry1.Close(); } if (this.IisVersion.Major >= 6) { this.AssignApplicationToPool(domain, str + "/" + name, applicationPool, 4); } if (this.IisVersion.Major >= 7 && !isNested) { using (ServerManager serverManager = new ServerManager()) { ConfigurationSection section = serverManager.GetApplicationHostConfiguration().GetSection("system.webServer/security/authentication/anonymousAuthentication", website.Name); section["enabled"] = (object)true; section["userName"] = (object)""; section["password"] = (object)""; serverManager.CommitChanges(); } this.RegisterWcf(); } return(new RayvarzInstaller.ModernUI.App.Models.VirtualDirectory(name, str + "/" + name)); }
public List <RayvarzInstaller.ModernUI.App.Models.VirtualDirectory> GetVirtualDirectories(WebSiteEntry webSite) { string path = webSite.Path + "/Root"; var virtualDirectoryList = new List <RayvarzInstaller.ModernUI.App.Models.VirtualDirectory>(); using (DirectoryEntry directoryEntry = new DirectoryEntry(path)) { directoryEntry.RefreshCache(); foreach (DirectoryEntry child in directoryEntry.Children) { try { if (child.SchemaClassName.ToLower() == "iiswebvirtualdir") { virtualDirectoryList.Add(new RayvarzInstaller.ModernUI.App.Models.VirtualDirectory(child.Name, child.Path)); } } catch { } } } return(virtualDirectoryList); }