![](/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.