Esempio n. 1
0
        public static bool DeleteSite(IISIdentifier siteIdentifier)
        {
            if (!(siteIdentifier is IISServerCommentIdentifier))
            {
                throw new Exception(String.Format("Identifier not yet supported {}", siteIdentifier.GetType().Name));
            }
            ServerManager sm   = new ServerManager();
            Site          site = sm.Sites[siteIdentifier.Value];

            if (site == null)
            {
                return(false);
            }
            //if this site is in a bad state, the following calls will fail so we will just trap the exception for now
            try { site.Stop(); }
            catch { }
            sm.Sites.Remove(site);
            sm.CommitChanges();
            return(true);
        }
Esempio n. 2
0
        public static bool TryGetSiteID(IISIdentifier Identifier, ref String SiteId)
        {
            if (!(Identifier is IISServerCommentIdentifier))
            {
                throw new Exception(String.Format("IISIdentifier's of type {0} are not yet supported in TryGetSiteID", Identifier.GetType().Name));
            }
            DirectoryEntry iis = GetIIsWebService();

            foreach (DirectoryEntry entry in iis.Children)
            {
                if (entry.SchemaClassName.Equals("iiswebserver", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (entry.Properties["ServerComment"].Value.ToString().Equals(Identifier.Value, StringComparison.CurrentCultureIgnoreCase))
                    {
                        SiteId = entry.Name;
                        return(true);
                    }
                }
            }
            return(false);
        }