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); }
private void ConnectToServer() { string path = "IIS://" + server + "/W3SVC/" + website + "/ROOT"; try { this.rootfolder = new DirectoryEntry(path); virtualDirectories = GetVirtualDirectories(this.rootfolder.Children); } catch (Exception ex) { throw new Exception("Can''t connect to the server [" + server + "] ...", ex); } }
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; }
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; }
private void Close() { virtualDirectories.Clear(); virtualDirectories = null; rootfolder.Dispose(); }
public void UpdateBatch(VirtualDirectories vds) { BatchUpdate(vds); }