如何使用 C# 更改 IIS FTP 上的 read/write 权限?
How change read/write permissions on IIS FTP using C#?
我在许多 IIS FTP 站点(多个服务器 2008-2019)的只写根文件夹下使用 C# 创建子文件夹。当我创建子文件夹时,它从根目录继承了只写 "FTP Authorization"。如何使用 C# 将新创建的子文件夹的 FTP 授权更改为 read/write?
以下是我如何将 FTP 授权规则添加到特定路径上的 IIS FTP 站点。
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();
}
其中 "FTP/LDNClient/Reports/" + itm["ftpClientName"] 是我需要更新的路径。
我在许多 IIS FTP 站点(多个服务器 2008-2019)的只写根文件夹下使用 C# 创建子文件夹。当我创建子文件夹时,它从根目录继承了只写 "FTP Authorization"。如何使用 C# 将新创建的子文件夹的 FTP 授权更改为 read/write?
以下是我如何将 FTP 授权规则添加到特定路径上的 IIS FTP 站点。
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();
}
其中 "FTP/LDNClient/Reports/" + itm["ftpClientName"] 是我需要更新的路径。