コード例 #1
0
        public static PropertyBag SerializeSiteDefaults(ServerManager serverManager)
        {
            FtpSite     ftpSiteDefaultElement = FtpHelper.GetFtpSiteDefaultElement(serverManager.SiteDefaults);
            PropertyBag bag = new PropertyBag(true);

            SerializeFtpSiteProperties(ftpSiteDefaultElement, bag);
            return(bag);
        }
コード例 #2
0
 public void EditSiteDefaults(PropertyBag bag)
 {
     if (bag == null)
     {
         throw new ArgumentNullException("bag");
     }
     SitesHelper.DeserializeFtpSiteProperties(FtpHelper.GetFtpSiteDefaultElement(ServerManager.SiteDefaults), bag);
     ServerManager.CommitChanges();
 }
コード例 #3
0
        /// <summary>
        /// Gets authorization collection for a given site.
        /// </summary>
        /// <param name="siteName">Site's name to get authorization collection for.</param>
        /// <returns>Authorization collection.</returns>
        public AuthorizationRuleCollection GetAuthorizationRuleCollection(string siteName)
        {
            AuthorizationSection        section = (AuthorizationSection)FtpHelper.GetAppHostSection(ServerManager, "system.ftpServer/security/authorization", typeof(AuthorizationSection), ManagementConfigurationPath.CreateSiteConfigurationPath(siteName));
            AuthorizationRuleCollection rules   = section.Rules;

            if (rules == null)
            {
                throw new Exception("ConfigurationError");
            }
            return(rules);
        }
コード例 #4
0
        /// <summary>
        /// Gets ftp site with given name.
        /// </summary>
        /// <param name="siteName">Site's name.</param>
        /// <returns>Ftp site.</returns>
        public FtpSite GetIisFtpSite(string siteName)
        {
            Site site = this.GetIisSite(siteName);

            if (site == null)
            {
                throw new ArgumentException("Site with given name doesn't exist.", "siteName");
            }
            FtpSite ftpSiteElement = FtpHelper.GetFtpSiteElement(site);

            ftpSiteElement.SiteServiceId = Convert.ToString(site.Id);
            //
            return(ftpSiteElement);
        }
コード例 #5
0
        public PropertyBag GetSiteProperties(string siteName)
        {
            if (string.IsNullOrEmpty(siteName))
            {
                throw new ArgumentNullException(siteName);
            }
            Site site = ServerManager.Sites[siteName];

            if (site == null)
            {
                throw new Exception("SiteDoesNotExistExceptionError");
            }

            PropertyBag bag = SitesHelper.SerializeSite(site);

            SitesHelper.SerializeFtpSiteProperties(FtpHelper.GetFtpSiteElement(site), bag);
            return(bag);
        }
コード例 #6
0
        public PropertyBag EditSiteProperties(PropertyBag bag)
        {
            if (bag == null)
            {
                throw new ArgumentNullException("bag");
            }
            string      siteName   = (string)bag[100];
            PropertyBag bindingBag = (PropertyBag)bag[0x68];

            if (bindingBag != null)
            {
                this.AddSiteBinding(siteName, bindingBag);
            }
            Site site = ServerManager.Sites[siteName];

            if (site == null)
            {
                throw new Exception("SiteDoesNotExistCannotEditExceptionError");
            }

            SitesHelper.DeserializeSiteProperties(site, bag);
            PropertyBag authBag = (PropertyBag)bag[0x1a6];

            if (authBag != null)
            {
                this.AddAuthorizationRules(siteName, authBag);
            }
            //
            ServerManager.CommitChanges();
            //
            site = ServerManager.Sites[siteName];
            try
            {
                FtpSite ftpSiteElement = FtpHelper.GetFtpSiteElement(site);
                if (ftpSiteElement.ServerAutoStart)
                {
                    ftpSiteElement.Start();
                }
            }
            catch
            {
            }
            return(SitesHelper.SerializeSite(site));
        }