private void UpdateVirtualDirectoryInfo(DirectoryEntry de, VirtualDirectory vd) { de.Properties["AnonymousUserName"][0] = vd.AnonymousUserName; de.Properties["AnonymousUserPass"][0] = vd.AnonymousUserPass; de.Properties["AccessRead"][0] = vd.AccessRead; de.Properties["AccessExecute"][0] = vd.AccessExecute; de.Properties["AccessWrite"][0] = vd.AccessWrite; de.Properties["AuthBasic"][0] = vd.AuthBasic; de.Properties["AuthNTLM"][0] = vd.AuthNTLM; de.Properties["ContentIndexed"][0] = vd.ContentIndexed; de.Properties["EnableDefaultDoc"][0] = vd.EnableDefaultDoc; de.Properties["EnableDirBrowsing"][0] = vd.EnableDirBrowsing; de.Properties["AccessSSL"][0] = vd.AccessSSL; de.Properties["AccessScript"][0] = vd.AccessScript; de.Properties["DefaultDoc"][0] = vd.DefaultDoc; de.Properties["Path"][0] = vd.PhysicalPath; de.CommitChanges(); }
private void BatchUpdate(VirtualDirectories vds) { batchflag = true; foreach (object item in vds.Values) { VirtualDirectory vd = (VirtualDirectory)item; switch (vd.Flag) { case 0: break; case 1: CreateVirtualDirectory(vd); break; case 2: UpdateVirtualDirecotry(vd); break; } } batchflag = false; }
public bool CreateVirtualDirectory(VirtualDirectory vd) { string path = "IIS://" + server + "/W3SVC/" + website + "/ROOT/" + vd.Name; if (!virtualDirectories.Contains(vd.Name) || batchflag) { try { if (!Directory.Exists(vd.PhysicalPath)) Directory.CreateDirectory(vd.PhysicalPath); DirectoryEntry myDE = rootfolder.Children.Add(vd.Name, SCHEMACLASS_NAME); myDE.Invoke("AppCreate", true); myDE.CommitChanges(); rootfolder.CommitChanges(); UpdateVirtualDirectoryInfo(myDE, vd); return true; } catch { return false; } } else { return true; } }
private VirtualDirectories GetVirtualDirectories(DirectoryEntries des) { VirtualDirectories tmpdirs = new VirtualDirectories(); foreach (DirectoryEntry de in des) { if (de.SchemaClassName == SCHEMACLASS_NAME) { VirtualDirectory vd = new VirtualDirectory(); vd.Name = de.Name; vd.AccessRead = (bool)de.Properties["AccessRead"][0]; vd.AccessExecute = (bool)de.Properties["AccessExecute"][0]; vd.AccessWrite = (bool)de.Properties["AccessWrite"][0]; vd.AnonymousUserName = (string)de.Properties["AnonymousUserName"][0]; vd.AnonymousUserPass = (string)de.Properties["AnonymousUserName"][0]; vd.AuthBasic = (bool)de.Properties["AuthBasic"][0]; vd.AuthNTLM = (bool)de.Properties["AuthNTLM"][0]; vd.ContentIndexed = (bool)de.Properties["ContentIndexed"][0]; vd.EnableDefaultDoc = (bool)de.Properties["EnableDefaultDoc"][0]; vd.EnableDirBrowsing = (bool)de.Properties["EnableDirBrowsing"][0]; vd.AccessSSL = (bool)de.Properties["AccessSSL"][0]; vd.AccessScript = (bool)de.Properties["AccessScript"][0]; vd.PhysicalPath = (string)de.Properties["Path"][0]; vd.Flag = 0; vd.DefaultDoc = (string)de.Properties["DefaultDoc"][0]; tmpdirs.Add(vd.Name, vd); } } return tmpdirs; }
public void UpdateVirtualDirecotry(VirtualDirectory vd) { //判断需要更改的虚拟目录是否存在 if (virtualDirectories.Contains(vd.Name)) { DirectoryEntry ode = rootfolder.Children.Find(vd.Name, SCHEMACLASS_NAME); UpdateVirtualDirectoryInfo(ode, vd); } }