Previous Next

Thread: System.DirectoryServices and IIS7

Last post 09-24-2008 5:34 AM by pushack. 6 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (7 items)

Sort Posts:

  • 07-10-2007, 2:26 AM

    • jrista
    • Not Ranked
    • Joined on 07-10-2007, 2:21 AM
    • Posts 7

    System.DirectoryServices and IIS7

    I am curious about using System.DirectoryServices with IIS7. I have the need to configure multiple IIS servers, with versions ranging from IIS5 through IIS7 (the IIS 7 servers are currently running on Vista Ultimate). Whenever I create a DirectoryEntry using the following code on IIS7/VistaUltimate, just about everything throws System.Runtime.InteropServices.COMException: DirectoryEntry entry = new DirectoryEntry("IIS://localhost/W3SVC"); DirectoryEntry entry = new DirectoryEntry("IIS://localhost/W3SVC/1"); DirectoryEntry entry = new DirectoryEntry("IIS://localhost/W3SVC/1/ROOT"); I know there is this wonderful new Microsoft.Web.Administration namespace for administering IIS7, but that provides me with no value when I need to configure IIS5 and IIS6 servers as well. I do not have the desire nor time to write and maintain two sets of code to manage IIS7 differently than IIS5/6, so I am hoping there is something I can do to get standard System.DirectoryServices stuff working with IIS7. I am guessing there is some kind of permissions problem, but I havn't been able to find any other information about this problem. I greatly appreciate any help.
  • 07-10-2007, 2:02 PM In reply to

    • ksingla
    • Top 10 Contributor
    • Joined on 06-13-2006, 11:02 PM
    • Redmond, WA
    • Posts 547

    Re: System.DirectoryServices and IIS7

    Do you UAC disabled? Are you running the program in administrator's window?

  • 07-20-2007, 11:36 AM In reply to

    Re: System.DirectoryServices and IIS7

    Do you have the IIS 6 Management Compatibility turned on?  It should work then (works for me and breaks if that is turned off).

     Control Panel -> Programs and Features -> Turn Windows Features on or off -> Internet Information Services -> IIS 6 Management Compatibility

    HTH

  • 08-20-2008, 10:20 PM In reply to

    • jasonyin
    • Not Ranked
    • Joined on 08-21-2008, 2:19 AM
    • Posts 1

    Re: System.DirectoryServices and IIS7

    Hi, did you solve the problem? I met the same problem with you.

  • 08-23-2008, 12:45 PM In reply to

    • jrista
    • Not Ranked
    • Joined on 07-10-2007, 2:21 AM
    • Posts 7

    Re: System.DirectoryServices and IIS7

    I never did. I tried for a while and finally gave up as there was no information or help on the subject at the time.
  • 08-24-2008, 11:42 AM In reply to

    Re: System.DirectoryServices and IIS7

    Did you install the Compat layer the previous poster indicated?

    Steve Schofield
    Windows Server MVP - IIS
    http://weblogs.asp.net/steveschofield

    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget
  • 09-24-2008, 5:34 AM In reply to

    • pushack
    • Not Ranked
    • Joined on 09-23-2008, 5:17 PM
    • Posts 1

    Re: System.DirectoryServices and IIS7

    I have exactly same problem as jrista. I had to test our software on Windows 2008 (with .NET 3.5 SP1). I’ve installed ‘IIS 6 Management Compatibility’ and UAC is turned off. Our software is using quite same code as jrista ‘System.DirectoryServices’ and ADSI. I’ve tried 2 scenarios:

    1) Run the code from my XP machine trying to manage IIS 7 on windows 2008 Server.

    2) Run the code directly on Windows 2008.

    In both scenarios I was using the same AD Account, which has administrative rights on both machines. Results:

    1) COMException: “Access is denied.” (source: "System.DirectoryServices")

    2) Test run successfully and I get access to IIS7

    I’ve tried also to run a VBScript also using ADSI:

    dim websrv, site

    set websrv = getobject("IIS://windows2008server/W3SVC")

    for each site in websrv

    if (site.classname = "IIsWebServer") then

    WScript.echo Site.ServerComment & " (" & Site.Name & ")"

    end if next

    And the curious thing is that vbs script works in both scenarios. Currently I have no idea, how to get the 1 scenario running. I think it could be some kind of .NET security problem. Thanks for any ideas.

    _______________________________

    lukas radwanski
    Tags:
Page 1 of 1 (7 items)
Page view counter