예제 #1
0
        public virtual void CreateAccount(FtpAccount account)
        {
            Log.WriteInfo("GetFileZillaConfig");
            XmlDocument doc = GetFileZillaConfig();


            Log.WriteInfo("Find users nodes");
            // find users node
            XmlNode fzServerNode   = doc.SelectSingleNode("FileZillaServer");
            XmlNode fzAccountsNode = fzServerNode.SelectSingleNode("Users");

            if (fzAccountsNode == null)
            {
                fzAccountsNode = doc.CreateElement("Users");
                fzServerNode.AppendChild(fzAccountsNode);
            }

            XmlElement fzAccountNode = doc.CreateElement("User");

            fzAccountsNode.AppendChild(fzAccountNode);
            // set properties
            fzAccountNode.SetAttribute("Name", account.Name);
            SetOption(fzAccountNode, "Pass", MD5(account.Password));
            SetOption(fzAccountNode, "Group", "");
            SetOption(fzAccountNode, "Bypass server userlimit", "0");
            SetOption(fzAccountNode, "User Limit", "0");
            SetOption(fzAccountNode, "IP Limit", "0");
            SetOption(fzAccountNode, "Enabled", BoolToString(account.Enabled));
            SetOption(fzAccountNode, "Comments", "");
            SetOption(fzAccountNode, "ForceSsl", "0");

            // IP filter
            XmlElement nodeIPFilter = doc.CreateElement("IpFilter");

            fzAccountNode.AppendChild(nodeIPFilter);

            XmlElement nodeDisallowed = doc.CreateElement("Disallowed");

            nodeIPFilter.AppendChild(nodeDisallowed);

            XmlElement nodeAllowed = doc.CreateElement("Allowed");

            nodeIPFilter.AppendChild(nodeAllowed);

            // folder
            XmlElement nodePermissions = doc.CreateElement("Permissions");

            fzAccountNode.AppendChild(nodePermissions);

            XmlElement nodePermission = doc.CreateElement("Permission");

            nodePermissions.AppendChild(nodePermission);

            // folder settings
            nodePermission.SetAttribute("Dir", account.Folder);
            SetOption(nodePermission, "FileRead", BoolToString(account.CanRead));
            SetOption(nodePermission, "FileWrite", BoolToString(account.CanWrite));
            SetOption(nodePermission, "FileDelete", BoolToString(account.CanWrite));
            SetOption(nodePermission, "FileAppend", BoolToString(account.CanWrite));  //JSR
            SetOption(nodePermission, "DirCreate", BoolToString(account.CanWrite));
            SetOption(nodePermission, "DirDelete", BoolToString(account.CanWrite));
            SetOption(nodePermission, "DirList", BoolToString(account.CanRead));
            SetOption(nodePermission, "DirSubdirs", BoolToString(account.CanRead));
            SetOption(nodePermission, "IsHome", "1");
            SetOption(nodePermission, "AutoCreate", "0");

            // speed limits
            XmlElement nodeSpeedLimits = doc.CreateElement("SpeedLimits");

            fzAccountNode.AppendChild(nodeSpeedLimits);
            nodeSpeedLimits.SetAttribute("DlType", "0");
            nodeSpeedLimits.SetAttribute("DlLimit", "10");
            nodeSpeedLimits.SetAttribute("ServerDlLimitBypass", "0");
            nodeSpeedLimits.SetAttribute("UlType", "0");
            nodeSpeedLimits.SetAttribute("UlLimit", "10");
            nodeSpeedLimits.SetAttribute("ServerUlLimitBypass", "0");

            XmlElement nodeDownload = doc.CreateElement("Download");

            nodeSpeedLimits.AppendChild(nodeDownload);

            XmlElement nodeUpload = doc.CreateElement("Upload");

            nodeSpeedLimits.AppendChild(nodeUpload);

            // save document
            doc.Save(GetFileZillaConfigPath());

            // reload config
            ReloadFileZillaConfig();
        }
예제 #2
0
 /// <remarks/>
 public void UpdateAccountAsync(FtpAccount account)
 {
     this.UpdateAccountAsync(account, null);
 }
예제 #3
0
 public void UpdateAccount(FtpAccount account)
 {
     this.Invoke("UpdateAccount", new object[] {
         account
     });
 }
예제 #4
0
 /// <remarks/>
 public System.IAsyncResult BeginUpdateAccount(FtpAccount account, System.AsyncCallback callback, object asyncState)
 {
     return(this.BeginInvoke("UpdateAccount", new object[] {
         account
     }, callback, asyncState));
 }
예제 #5
0
 /// <remarks/>
 public void CreateAccountAsync(FtpAccount account)
 {
     this.CreateAccountAsync(account, null);
 }