public void SaveItem(FtpAccount item)
 {
     item.CanRead  = chkRead.Checked;
     item.CanWrite = chkWrite.Checked;
 }
 public PanelResult DomainAddFtpAccount(FtpAccount account)
 {
     throw new NotImplementedException();
 }
 public void BindItem(FtpAccount item)
 {
     chkRead.Checked  = item.CanRead;
     chkWrite.Checked = item.CanWrite;
 }
Exemple #4
0
 public int AddFtpAccount(FtpAccount item)
 {
     return(FtpServerController.AddFtpAccount(item));
 }
Exemple #5
0
 public int UpdateFtpAccount(FtpAccount item)
 {
     return(FtpServerController.UpdateFtpAccount(item));
 }
        public void DomainAddFtpAccount()
        {
            FtpAccount ftpAccount = new FtpAccount();

            ftpAccount.Name = "ozgurmazlum.com";
            ftpAccount.Account = "ftpTest";
            ftpAccount.Password = "******";
            ftpAccount.HomePath = "/veritabani";
            ftpAccount.Ronly = false;

            PanelResult result = panel.DomainAddFtpAccount(ftpAccount);

            Assert.AreEqual(200, result.Code);
        }
Exemple #7
0
        public int CreateUserAccountInternal(int parentPackageId, string username, string password,
                                             int roleId, string firstName, string lastName, string email, string secondaryEmail, bool htmlMail,
                                             bool sendAccountLetter,
                                             bool createPackage, int planId, bool sendPackageLetter,
                                             string domainName, bool tempDomain, bool createWebSite,
                                             bool createFtpAccount, string ftpAccountName, bool createMailAccount, string hostName, bool createZoneRecord)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive
                                                            | DemandAccount.IsReseller);

            if (accountCheck < 0)
            {
                return(accountCheck);
            }

            // check package
            int packageCheck = SecurityContext.CheckPackage(parentPackageId, DemandPackage.IsActive);

            if (packageCheck < 0)
            {
                return(packageCheck);
            }

            // check if username exists
            if (UserController.UserExists(username))
            {
                return(BusinessErrorCodes.ERROR_ACCOUNT_WIZARD_USER_EXISTS);
            }

            // check if domain exists
            int checkDomainResult = ServerController.CheckDomain(domainName);

            if (checkDomainResult < 0)
            {
                return(checkDomainResult);
            }

            // check if FTP account exists
            if (String.IsNullOrEmpty(ftpAccountName))
            {
                ftpAccountName = username;
            }

            if (FtpServerController.FtpAccountExists(ftpAccountName))
            {
                return(BusinessErrorCodes.ERROR_ACCOUNT_WIZARD_FTP_ACCOUNT_EXISTS);
            }

            // load parent package
            PackageInfo parentPackage = PackageController.GetPackage(parentPackageId);

            /********************************************
             *  CREATE USER ACCOUNT
             * *****************************************/
            UserInfo user = new UserInfo();

            user.RoleId   = roleId;
            user.StatusId = (int)UserStatus.Active;
            user.OwnerId  = parentPackage.UserId;
            user.IsDemo   = false;
            user.IsPeer   = false;

            // account info
            user.FirstName      = firstName;
            user.LastName       = lastName;
            user.Email          = email;
            user.SecondaryEmail = secondaryEmail;
            user.Username       = username;
//            user.Password = password;
            user.HtmlMail = htmlMail;

            // add a new user
            createdUserId = UserController.AddUser(user, false, password);
            if (createdUserId < 0)
            {
                // exit
                return(createdUserId);
            }
            userCreated = true;

            // create package
            // load hosting plan
            createdPackageId = -1;
            if (createPackage)
            {
                try
                {
                    HostingPlanInfo plan = PackageController.GetHostingPlan(planId);

                    PackageResult packageResult = PackageController.AddPackage(
                        createdUserId, planId, plan.PlanName, "", (int)PackageStatus.Active, DateTime.Now, false);
                    createdPackageId = packageResult.Result;
                }
                catch (Exception ex)
                {
                    // error while adding package

                    // remove user account
                    UserController.DeleteUser(createdUserId);

                    throw ex;
                }

                if (createdPackageId < 0)
                {
                    // rollback wizard
                    Rollback();

                    // return code
                    return(createdPackageId);
                }

                // create domain
                int domainId = 0;
                if ((createWebSite || createMailAccount || createZoneRecord) && !String.IsNullOrEmpty(domainName))
                {
                    try
                    {
                        DomainInfo domain = new DomainInfo();
                        domain.PackageId      = createdPackageId;
                        domain.DomainName     = domainName;
                        domain.HostingAllowed = false;
                        domainId = ServerController.AddDomain(domain, false, false);
                        if (domainId < 0)
                        {
                            // rollback wizard
                            Rollback();

                            // return
                            return(domainId);
                        }
                    }
                    catch (Exception ex)
                    {
                        // rollback wizard
                        Rollback();

                        // error while adding domain
                        throw new Exception("Could not add domain", ex);
                    }
                }

                if (createWebSite && (domainId > 0))
                {
                    // create web site
                    try
                    {
                        int webSiteId = WebServerController.AddWebSite(
                            createdPackageId, hostName, domainId, 0, true, false);
                        if (webSiteId < 0)
                        {
                            // rollback wizard
                            Rollback();

                            // return
                            return(webSiteId);
                        }
                    }
                    catch (Exception ex)
                    {
                        // rollback wizard
                        Rollback();

                        // error while creating web site
                        throw new Exception("Could not create web site", ex);
                    }
                }

                // create FTP account
                if (createFtpAccount)
                {
                    try
                    {
                        FtpAccount ftpAccount = new FtpAccount();
                        ftpAccount.PackageId = createdPackageId;
                        ftpAccount.Name      = ftpAccountName;
                        ftpAccount.Password  = password;
                        ftpAccount.Folder    = "\\";
                        ftpAccount.CanRead   = true;
                        ftpAccount.CanWrite  = true;

                        int ftpAccountId = FtpServerController.AddFtpAccount(ftpAccount);
                        if (ftpAccountId < 0)
                        {
                            // rollback wizard
                            Rollback();

                            // return
                            return(ftpAccountId);
                        }
                    }
                    catch (Exception ex)
                    {
                        // rollback wizard
                        Rollback();

                        // error while creating ftp account
                        throw new Exception("Could not create FTP account", ex);
                    }
                }

                if (createMailAccount && (domainId > 0))
                {
                    // create default mailbox
                    try
                    {
                        // load mail policy
                        UserSettings settings     = UserController.GetUserSettings(createdUserId, UserSettings.MAIL_POLICY);
                        string       catchAllName = !String.IsNullOrEmpty(settings["CatchAllName"])
                            ? settings["CatchAllName"] : "mail";

                        MailAccount mailbox = new MailAccount();
                        mailbox.Name      = catchAllName + "@" + domainName;
                        mailbox.PackageId = createdPackageId;

                        // gather information from the form
                        mailbox.Enabled = true;

                        mailbox.ResponderEnabled = false;
                        mailbox.ReplyTo          = "";
                        mailbox.ResponderSubject = "";
                        mailbox.ResponderMessage = "";

                        // password
                        mailbox.Password = password;

                        // redirection
                        mailbox.ForwardingAddresses = new string[] { };
                        mailbox.DeleteOnForward     = false;
                        mailbox.MaxMailboxSize      = 0;

                        int mailAccountId = MailServerController.AddMailAccount(mailbox);

                        if (mailAccountId < 0)
                        {
                            // rollback wizard
                            Rollback();

                            // return
                            return(mailAccountId);
                        }

                        // set catch-all account
                        MailDomain mailDomain = MailServerController.GetMailDomain(createdPackageId, domainName);
                        mailDomain.CatchAllAccount   = "mail";
                        mailDomain.PostmasterAccount = "mail";
                        mailDomain.AbuseAccount      = "mail";
                        MailServerController.UpdateMailDomain(mailDomain);

                        int mailDomainId = mailDomain.Id;
                    }
                    catch (Exception ex)
                    {
                        // rollback wizard
                        Rollback();

                        // error while creating mail account
                        throw new Exception("Could not create mail account", ex);
                    }
                }

                // Preview Domain / Temporary URL
                if (tempDomain && (domainId > 0))
                {
                    int previewDomainId = ServerController.CreateDomainPreviewDomain("", domainId);
                    if (previewDomainId < 0)
                    {
                        // rollback wizard
                        Rollback();

                        return(previewDomainId);
                    }
                }

                // Domain DNS Zone
                if (createZoneRecord && (domainId > 0))
                {
                    ServerController.EnableDomainDns(domainId);
                }
            }

            // send welcome letters
            if (sendAccountLetter)
            {
                int result = PackageController.SendAccountSummaryLetter(createdUserId, null, null, true);
                if (result < 0)
                {
                    // rollback wizard
                    Rollback();

                    // return
                    return(result);
                }
            }

            if (createPackage && sendPackageLetter)
            {
                int result = PackageController.SendPackageSummaryLetter(createdPackageId, null, null, true);
                if (result < 0)
                {
                    // rollback wizard
                    Rollback();

                    // return
                    return(result);
                }
            }

            return(createdUserId);
        }
        public void DomainChangeFtpPassword()
        {
            FtpAccount ftpAccount = new FtpAccount();

            string name = "ozgurmazlum.com";
            string account = "ftpTest";
            string newPassword = "******";

            PanelResult result = panel.DomainChangeFtpPassword(name, account,newPassword);

            Assert.AreEqual(200, result.Code);
        }
        public void DomainDeleteFtpAccount()
        {
            FtpAccount ftpAccount = new FtpAccount();

            string name = "ozgurmazlum.com";
            string account = "ftpTest";

            PanelResult result = panel.DomainDeleteFtpAccount(name, account);

            Assert.AreEqual(200, result.Code);
        }
        private void SaveItem()
        {
            if (!Page.IsValid)
            {
                return;
            }

            // get form data
            FtpAccount item = new FtpAccount();

            item.Id        = PanelRequest.ItemID;
            item.PackageId = PanelSecurity.PackageId;
            item.Name      = usernameControl.Text;
            item.Password  = passwordControl.Password;
            item.Folder    = fileLookup.SelectedFile;

            // get other props
            IFtpAccountEditControl ctrl = (IFtpAccountEditControl)providerControl.Controls[0];

            ctrl.SaveItem(item);

            if (PanelRequest.ItemID == 0)
            {
                try
                {
                    // new item
                    int result = ES.Services.FtpServers.AddFtpAccount(item);
                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("FTP_ADD_ACCOUNT", ex);
                    return;
                }
            }
            else
            {
                try
                {
                    // existing item
                    int result = ES.Services.FtpServers.UpdateFtpAccount(item);
                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("FTP_UPDATE_ACCOUNT", ex);
                    return;
                }
            }

            // return
            RedirectSpaceHomePage();
        }
        private void BindItem()
        {
            try
            {
                if (!IsPostBack)
                {
                    // load item if required
                    if (PanelRequest.ItemID > 0)
                    {
                        // existing item
                        try
                        {
                            item = ES.Services.FtpServers.GetFtpAccount(PanelRequest.ItemID);
                        }
                        catch (Exception ex)
                        {
                            ShowErrorMessage("FTP_GET_ACCOUNT", ex);
                            return;
                        }

                        if (item != null)
                        {
                            // save package info
                            ViewState["PackageId"] = item.PackageId;
                            fileLookup.PackageId   = item.PackageId;
                            passwordControl.SetPackagePolicy(item.PackageId, UserSettings.FTP_POLICY, "UserPasswordPolicy");
                        }
                        else
                        {
                            RedirectToBrowsePage();
                        }
                    }
                    else
                    {
                        // new item
                        ViewState["PackageId"]  = PanelSecurity.PackageId;
                        fileLookup.PackageId    = PanelSecurity.PackageId;
                        fileLookup.SelectedFile = "\\";
                        usernameControl.SetPackagePolicy(PanelSecurity.PackageId, UserSettings.FTP_POLICY, "UserNamePolicy");
                        passwordControl.SetPackagePolicy(PanelSecurity.PackageId, UserSettings.FTP_POLICY, "UserPasswordPolicy");
                    }
                }

                // load provider control
                LoadProviderControl((int)ViewState["PackageId"], "Ftp", providerControl, "EditAccount.ascx");

                if (!IsPostBack)
                {
                    // bind item to controls
                    if (item != null)
                    {
                        // bind item to controls
                        usernameControl.Text     = item.Name;
                        usernameControl.EditMode = true;
                        passwordControl.EditMode = true;
                        fileLookup.SelectedFile  = item.Folder;

                        // other controls
                        IFtpAccountEditControl ctrl = (IFtpAccountEditControl)providerControl.Controls[0];
                        ctrl.BindItem(item);
                    }
                }
            }
            catch
            {
                ShowWarningMessage("INIT_SERVICE_ITEM_FORM");
                DisableFormControls(this, btnCancel);
            }
        }
 /// <remarks/>
 public void UpdateFtpAccountAsync(FtpAccount item)
 {
     this.UpdateFtpAccountAsync(item, null);
 }
 /// <remarks/>
 public System.IAsyncResult BeginUpdateFtpAccount(FtpAccount item, System.AsyncCallback callback, object asyncState)
 {
     return(this.BeginInvoke("UpdateFtpAccount", new object[] {
         item
     }, callback, asyncState));
 }
 /// <remarks/>
 public void AddFtpAccountAsync(FtpAccount item)
 {
     this.AddFtpAccountAsync(item, null);
 }
Exemple #15
0
 public FtpAccountInteraction(FtpAccount ftpAccount, string title)
 {
     FtpAccount = ftpAccount;
     Title      = title;
 }
Exemple #16
0
 private void AssertFtpAccountsAreEqual(FtpAccount first, FtpAccount second)
 {
     Assert.AreEqual(first.UserName, second.UserName);
     Assert.AreEqual(first.Password, second.Password);
     Assert.AreEqual(first.Server, second.Server);
 }