Quantcast
Channel: General
Viewing all articles
Browse latest Browse all 7363

Adding IIS FTP Authorization users for FTP website in FTP BaseProvider Initialize c#

$
0
0

Hi,

     I want to dynamically add users in IIS FTP Authorization through code, but its not working

     I tried below code thruough dll class library its not working    , but same code is working in a simple console application.

     Could anyone point me if i am doing anything wrong and guide the correct way

public class FtpAuthDemo : BaseProvider,        IFtpAuthenticationProvider,        IFtpLogProvider    {        protected override void Initialize(StringDictionary config)        {            using (ServerManager serverManager = new ServerManager())            {                Configuration configFile = serverManager.GetApplicationHostConfiguration();                ConfigurationSection authorizationSection = configFile.GetSection("system.ftpServer/security/authorization""MyCustomFTPSite");                if (authorizationSection != null)                {                    ConfigurationElementCollection authorizationCollection = authorizationSection.GetCollection();                    ConfigurationElement addElement = authorizationCollection.CreateElement("add");                    addElement["accessType"] = @"Deny";                    addElement["users"] = @"*";                    addElement["permissions"] = @"Read, Write";                    authorizationCollection.Add(addElement);                    ConfigurationElement addElement1 = authorizationCollection.CreateElement("add");                    addElement1["accessType"] = @"Allow";                    addElement1["users"] = @"guest";                    addElement1["permissions"] = @"Read, Write";                    authorizationCollection.Add(addElement1);                    serverManager.CommitChanges();                }            }        }    }


Thanks & Regards

Ajay S Bhalekar


Viewing all articles
Browse latest Browse all 7363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>