簡體   English   中英

如何使用 C# 更改 IIS FTP 上的讀/寫權限?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM