I create subfolders with C# under a write only root folder in a number of IIS FTP sites (multiple Servers 2008-2019). When I create the subfolder, it inherits the write-only "FTP Authorization" from it's root. How to I change the newly created subfolder's FTP Authorization to read/write with C#?
Here is how I added the FTP Authorization Rule to the IIS FTP site on a specific path.
using (ServerManager serverManager = new ServerManager())
{
Configuration config = serverManager.GetApplicationHostConfiguration();
ConfigurationSection authorizationSection = config.GetSection("system.ftpServer/security/authorization", "FTP/LDNClient/Reports/" + itm["ftpClientName"]);
ConfigurationElementCollection authorizationCollection = authorizationSection.GetCollection();
ConfigurationElement addElement = authorizationCollection.CreateElement("add");
addElement["accessType"] = @"Allow";
addElement["users"] = @"LDNClient";
addElement["roles"] = @"";
addElement["permissions"] = @"Read, Write";
authorizationCollection.Add(addElement);
serverManager.CommitChanges();
}
Where "FTP/LDNClient/Reports/" + itm["ftpClientName"] was the path I needed to update.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.