For IIS6, I would use the System.DirectoryServices namespace, which is a managed wrapper around ADSI. I find this easier to use than working with WMI IIS providers.
For IIS7 and Sealed Offers, I would use the new IIS 7 Managed Code Administration API ( Microsoft.Web.Administration et al). You can use IIS6 compatibility components on IIS7 that support the old-style ADSI APIs for consumers (but are a wrapper around the new IIS7 components), and they basically work.
However, you have encountered problems with ADSI wrappers. For example, they donβt know about the Mapping Handler (similar to the properties of IIS6 Script Map), for example preConditions , which, for example, allow several versions of ASP.NET handler display definitions to be shared in the same site or application. The ADSI compatibility level will create objects known as AboMapperCustom objects that are not optimal in configuration and are not aware of these new features.
Having two codebases (one for IIS6 and one for IIS7) may seem like a lot of work, but to be honest, it's not so bad. I work for a hoster, was on this road, and we removed the bullet and decided that we would keep the old IIS6 code, but we would restart using IIS7.
source share