Example #1
0
        public static IISSite FindSite(IISIdentifier Identifier)
        {
            IISServerManagerSite retVal = new IISServerManagerSite();

            if (Identifier is IISBindingIdentifier)
            {
                List <IISBinding> bindings = IISBindingParser.ParseToList(Identifier.Value);

                foreach (Site iisSite in retVal.ServerMgr.Sites)
                {
                    if (retVal.site != null)
                    {
                        break;
                    }
                    foreach (IISBinding query in bindings)
                    {
                        if (retVal.site != null)
                        {
                            break;
                        }
                        if (iisSite.Bindings.FirstOrDefault <Binding>(b => b.BindingInformation.Equals(query.SMBindString)) != null)
                        {
                            retVal.site = iisSite;
                        }
                    }
                }
            }
            else
            {
                retVal.site = retVal.ServerMgr.Sites[Identifier.Value];
            }
            //Return null if the site was not found
            return((retVal.site != null) ? retVal : null);
        }
Example #2
0
        //Return null if the site is not to be found
        public static IISWMISite FindSite(IISIdentifier Identifier)
        {
            String id = "";

            //need to be sure that the site exists or else it can throw an error
            if (IISWMIHelper.TryGetSiteID(Identifier, ref id))
            {
                return(new IISWMISite()
                {
                    SiteId = id
                });
            }
            return(null);
        }
Example #3
0
        public static bool DeleteSite(IISIdentifier siteIdentifier)
        {
            String id = "";

            //need to be sure that the site exists or else it can throw an error
            if (IISWMIHelper.TryGetSiteID(siteIdentifier, ref id))
            {
                DirectoryEntry webServer = IISWMIHelper.GetIIsWebServer(id);
                webServer.Invoke("Stop", null);
                webServer.DeleteTree();
                return(true);
            }
            return(false);
        }
Example #4
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);
        }
Example #5
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);
        }
Example #6
0
 public override IISSite FindSite(IISIdentifier siteIdentifier)
 {
     return(IISServerManagerSite.FindSite(siteIdentifier));
 }
Example #7
0
 public override bool DeleteSite(IISIdentifier siteIdentifier)
 {
     return(IISServerManagerSite.DeleteSite(siteIdentifier));
 }
Example #8
0
 public override IISSite FindSite(IISIdentifier siteIdentifier)
 {
     return(IISWMISite.FindSite(siteIdentifier));
 }
Example #9
0
 public override bool DeleteSite(IISIdentifier siteIdentifier)
 {
     return(IISWMISite.DeleteSite(siteIdentifier));
 }
Example #10
0
 public abstract IISSite FindSite(IISIdentifier siteIdentifier);
Example #11
0
 public abstract bool DeleteSite(IISIdentifier siteIdentifier);