![](/img/trans.png)
[英]Change / Check permissions (Read, Write,…) for the NETWORK SERVICE account with C#
[英]How change read/write permissions on IIS FTP using C#?
我在许多 IIS FTP 站点(多个服务器 2008-2019)的只写根文件夹下使用 C# 创建子文件夹。 当我创建子文件夹时,它从它的根继承了只写的“FTP 授权”。 如何将新创建的子文件夹的 FTP 授权更改为使用 C# 读/写?
下面是我如何将 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"] 是我需要更新的路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.