« Previous Next »

Thread: IIS 7 WMI buggy

Last post 08-21-2008 8:38 PM by sergeia. 8 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (9 items)

Sort Posts:

  • 07-07-2008, 11:17 AM

    IIS 7 WMI buggy

    I'm now convinced that the new IIS 7 WMI provider is full of bugs!
    I can't seem to implement any sort of advanced functionality without it breaking on me...
    (Which is probably why the only examples available are for very simple tasks!)

    I'm using System.Management in VB.NET by the way....

    A couple of examples:

    1. Unable to update the "Bindings" property of the Site object
      (And perhaps other objects as well)
      If I remove an item from the array and update it with .Put(). it doesn't return any errors but then again it doesn't remove the binding either, it just stays the same.

      Adding items seems to work ok.

      What is stranger is that if I remove an element and add a new one
      For example from:

      *:80:test1
      *:80:test2

      to:

      *:80:test1
      *:80:test3

      and then update it, the resulting bindings become

      *:80:test1
      *:80:test2
      *:80:test3


    2. Classes returned by GetSection have different Location and Path key properties to the same classes returned via either a query or GetInstances().

      These Location and Path keys should be fixed so that I can actually use them to get an updateably instance of a class.

    Is there someone at Microsoft I should be contacting directly about this? Someone on the IIS team perhaps?

     

  • 07-07-2008, 2:26 PM In reply to

    • sergeia
    • Top 75 Contributor
    • Joined on 04-14-2008, 8:47 PM
    • Posts 68

    Re: IIS 7 WMI buggy

    Martin, could you post more context? May be snippet of code that you are using.

    Thanks,

    Sergei 

     

  • 07-07-2008, 11:07 PM In reply to

    Re: IIS 7 WMI buggy

    For the first one.
    Note that I remove the last element from the array and set it.

    This also works if i create a brand new list of bindings from scratch. The WMI provider internally just adds those bindings on to the bindings in the IIS config.

    =============================

    'Setup options

    Dim cInfo As New ConnectionOptions

    cInfo.Timeout = TimeSpan.FromSeconds(10)

    cInfo.Authentication = AuthenticationLevel.PacketPrivacy

    'Setup path

    Dim sScope As New ManagementScope("\\.\root\WebAdministration", cInfo)

    sScope.Connect()

    'Get site

    Dim s As New ManagementObject(sScope, New ManagementPath("Site.Name='test3.com'"), Nothing)

    'Get existing bindings

    Dim bindings() As ManagementBaseObject = s.Properties("Bindings").Value

    'Delete the last 1

    ReDim Preserve bindings(bindings.Length - 2)

    'Assign the new bindings

    s.Properties("Bindings").Value = bindings

    s.Put()

  • 07-07-2008, 11:18 PM In reply to

    Re: IIS 7 WMI buggy

    For the second one.
    Notes: the class returned by getsection has invalid keys which means they can't be used to get the class directly (which is needed to update it) below.

    If you look at the keys from GetSection the Path property is "MACHINE/WEBROOT/APPHOST/test3.com" and the Location property is empty.

    The actual class on the other hand (when I find it using CIM Studio) has Path as "MACHINE/WEBROOT/APPHOST" and Location as "test3.com"

    I can edit the values to fix it but that is clearly a hack, so the bug should get fixed.

     ===================================================

    'Setup options

    Dim cInfo As New ConnectionOptions

    cInfo.Timeout = TimeSpan.FromSeconds(10)

    cInfo.Authentication = AuthenticationLevel.PacketPrivacy

    'Setup path

    Dim sScope As New ManagementScope("\\.\root\WebAdministration", cInfo)

    sScope.Connect()

    'Get site

    Dim s As New ManagementObject(sScope, New ManagementPath("Site.Name='test3.com'"), Nothing)

    'Get the section as returnedSection

    Dim inParams As ManagementBaseObject = s.GetMethodParameters("GetSection")

    inParams("SectionName") = "AnonymousAuthenticationSection"

    Dim outParams As ManagementBaseObject = s.InvokeMethod("GetSection", inParams, Nothing) Dim returnedSection As ManagementBaseObject = outParams("Section")

    'Now request the section directly using its keys

    Dim section As New ManagementObject(sScope, New ManagementPath("AnonymousAuthenticationSection.Path='" & returnedSection("Path") & "',Location='" & returnedSection("Location") & "'"), Nothing)

    section.Get()

    'Changing a property is what causes the updating to fail

    section("Username") = "test"

    section("Password") = "test"

    section.Put()

  • 07-16-2008, 6:23 AM In reply to

    Re: IIS 7 WMI buggy

    After a couple of weeks of banging my head against the wall i've decided to manually edit the applicationHost.config file to implement the broken functionality.

    Which brings me to a question: is there any sort of high-level xml api that is designed to work with the structure used in the IIS config files?
    (And allows accessing the files directly?)

    As the format is the same structure as the one used by System.Configuration I thought there would be something derived from that but I haven't found anything yet.

    (I can't use the Microsoft.Web.Administration api because it won't let me specify a custom admin login like WMI does...I wish I could!)

     

  • 07-16-2008, 6:22 PM In reply to

    • sergeia
    • Top 75 Contributor
    • Joined on 04-14-2008, 8:47 PM
    • Posts 68

    Re: IIS 7 WMI buggy

    You could use winrm with any server local tool that works for you. You could find more information on winrm here or here. You could use appcmd as your server side tool, Information on appcmd is available on TechNet and on this site. If you still cannot get functionality that you need, write script agains AppHost APIs and execute it remotely through winrm. IIS7 doesn't have XML kind of APIs, and we don't recommend direct modifications unless you know exactly what are you doing. Configuration is much more than XML configuration files.

    You also could install CTP2 of Powershell, CTP2 of IIS7 Powershell provider and use Powershell remotely. It is probably the most advanced way of dealing with IIS7 administration remotely.

    I already fixed issue with bindings, thanks for pointing to it.

    --Sergei

  • 07-17-2008, 2:40 AM In reply to

    Re: IIS 7 WMI buggy

    RE: fix for binding issue, what sort of timeframe are we looking at for a patch?

    Will it be a part of windows update or will I need to wait until sp1 or R2?

  • 08-21-2008, 7:26 PM In reply to

    • Matibo
    • Not Ranked
    • Joined on 08-10-2008, 2:57 AM
    • Posts 7

    Re: IIS 7 WMI buggy

    Are there any solutions out there to fix this problem yet?

    I have the same problem!

    thx for any suggestions!

    Matt 

     

  • 08-21-2008, 8:38 PM In reply to

    • sergeia
    • Top 75 Contributor
    • Joined on 04-14-2008, 8:47 PM
    • Posts 68

    Re: IIS 7 WMI buggy

    We don't have any way to deliver fixes besides shipping service pack or new release of OS. I hope you understand that there is lot of process involved besides debugging and coding fixes.

     

    --Sergei

Page 1 of 1 (9 items)