Ejemplo n.º 1
0
        public static int ChangeFrontPagePassword(int siteItemId, string password)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // load site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;

            // place log record
            TaskManager.StartTask("WEB_SITE", "CHANGE_FP_PASSWORD", siteItem.Name);
            TaskManager.ItemId = siteItemId;
            TaskManager.WriteParameter("FrontPage username", siteItem.FrontPageAccount);

            try
            {
                if (String.IsNullOrEmpty(siteItem.FrontPageAccount))
                    siteItem.FrontPageAccount = GetFrontPageUsername(siteItem.Name);

                WebServer web = new WebServer();
                ServiceProviderProxy.Init(web, siteItem.ServiceId);
                web.ChangeFrontPagePassword(siteItem.FrontPageAccount, password);

                // update site with FP account
                siteItem.FrontPagePassword = CryptoUtils.Encrypt(password);
                PackageController.UpdatePackageItem(siteItem);

                return 0;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }