Page 1 of 1

Documentation protocol to administer 14147

Posted: 2017-02-15 16:37
by lennartlettingweb
Hey guys,

I've been looking a lot and.. I still haven't found what I am looking for....

I want to remotely add and remove FileZilla Server users. I would like to use the protocol that runs over port 14147 for that (so I won't edit the local xml config file myself).

- Is there documentation available that describes this protocol?
- Is there maybe a .NET library available for basis tasks?

I have been checking the code already, but it seems pretty time consuming to get to the bottom of that.

Thanks for your answer!

Cheers Lennart

Re: Documentation protocol to administer 14147

Posted: 2017-02-15 16:56
by botg
The source code is the documentation, though it's gibberish.

There is no .NET library.

It's easier if you directly edit the XML.

Re: Documentation protocol to administer 14147

Posted: 2017-02-21 14:15
by lennartlettingweb
Actually, I found a very useful library and I successfully implemented it in a C# .NET application. I am now able to remotely administer my FTP users of the FileZilla server. The library can be found here: https://github.com/PolarbearDK/Miracle.FileZilla.Api.

Note: A directory won't be automatically created when adding a new home directory of a new user. I created a helper FTP user with access to the FTP root. This user helps me creating the home directory first (with the standard FTP .NET library). Afterwards the account information of the new user can be added.

To create the FTP folder:

Code: Select all

        // create user root folder using the FTP admin user
        WebRequest request = WebRequest.Create("ftp://" + ftpServerIp + "/" + newPathAndUsername);
        request.Method = WebRequestMethods.Ftp.MakeDirectory;
        request.Credentials = new NetworkCredential(ftpBasepathUser, ftpBasepathPassword);
        WebResponse webResponse = request.GetResponse();
To create the new user:

Code: Select all

            // create a user account using the FileZillaApi
            FileZillaApi fileZillaApi = new FileZillaApi(IPAddress.Parse(ftpServerIp), ftpServerPort);
            fileZillaApi.Connect(ftpServerPassword);

            // get the current settings
            AccountSettings accountSettings = fileZillaApi.GetAccountSettings();

            // add user
            var user = new User
            {
                UserName = newPathAndUsername,
                SharedFolders = new List<SharedFolder>()
                {
                    new SharedFolder()
                    {
                        Directory = ftpBasepath + newPathAndUsername,
                        AccessRights = AccessRights.DirCreate | AccessRights.DirDelete | AccessRights.DirList | AccessRights.DirSubdirs | AccessRights.FileAppend | AccessRights.FileDelete | AccessRights.FileRead | AccessRights.FileWrite | AccessRights.IsHome

                    }
                }
            };

            string ftpUserpassword = System.Web.Security.Membership.GeneratePassword(14, 4);
            user.AssignPassword(ftpUserpassword, fileZillaApi.ProtocolVersion);
            accountSettings.Users.Add(user);

            // save the account settings
            fileZillaApi.SetAccountSettings(accountSettings);

Thanks to the library of Philip Hoppe https://github.com/PolarbearDK