InteropServices.COMException: Access is denied

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default InteropServices.COMException: Access is denied

    Hi,

    I want to create a virtual directory when a user has filled a form on an
    ASP.net page. It works well on my dev server, but when I try it on my
    production server, it fails. I got this error:

    System.Runtime.InteropServices.COMException (0x80070005): Access is denied
    at System.DirectoryServices.DirectoryEntry.Bind(Boole an throwIfFail)
    at System.DirectoryServices.DirectoryEntry.Bind()
    at System.DirectoryServices.DirectoryEntry.get_IsCont ainer()
    at System.DirectoryServices.ChildEnumerator..ctor(Dir ectoryEntry container)
    at System.DirectoryServices.DirectoryEntries.GetEnume rator()

    This is my code:

    DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC");
    int siteId = 1;
    IEnumerator list = root.Children.GetEnumerator();
    while (list.MoveNext() && !isFound)
    {
    DirectoryEntry e = (DirectoryEntry)list.Current;
    if(e.SchemaClassName == "IIsWebServer")
    {
    string desc = (string)e.Invoke("Get","ServerComment");
    if(desc == LIVESNAP_NAME)
    {
    siteId = Convert.ToInt32(e.Name);
    isFound = true;
    }
    }
    }

    I tried setting full control to everyone: It failed.
    I tries impersonation with an admin account: it works
    I tries impersonation with a power user acount: it works sometimes...

    How can have this to work without using an admin account? I think this is
    not really secure to use an admin username an password in the web.config
    file...

    Any idea?

    Thanks

    Stephane

    Stephane Guest

  2. Similar Questions and Discussions

    1. AxAcroPDF -System.Runtime.InteropServices.COMException
      When using the AxAcroPDF Control, I receive: System.Runtime.InteropServices.COMException (0x80004005): Unspecified error The odd part is the...
    2. Urgent Help: System.Runtime.interopservices.COMException 0x80010105
      Hi Gurus, I can instantiate a COM object in VC# without any problem. But when i call one function exported by the COM object i get this...
    3. Unhandled Execution Error: System.Runtime.InteropServices.COMException
      Hi, setup: - two MCMS2002 in an AC Cluster (newest Service Packs) with Framework 1.0 - SQL-Cluster following problem: - Web-Site normaly...
    4. System.Runtime.InteropServices.COMException Error
      I created a project that has OWC10 reference in c#. When I run it from VS.Studio it works fine. However, when I copy the project to the...
    5. System.Runtime.InteropServices.COMException - Catastrophic Exception
      I'm trying to generate excel sheet using SpeedGen COM object. I'm getting 'Catastrophic exception,Error code : 2147418113' when i try to access...
  3. #2

    Default Re: InteropServices.COMException: Access is denied

    You need to have adequate permissions to change the metabase. That
    generally involves having an admin level account. If you aren't comfortable
    with that, then you probably shouldn't be providing this functionality.

    You could move the IIS code to a COM+ DLL under a different identity if you
    wanted to make it so that the web application itself didn't have these
    privileges, but you still need to ensure that only authorized callers access
    your COM+ DLL.

    Joe K.

    "Stephane" <Stephane@discussions.microsoft.com> wrote in message
    news:FADEF0FD-6C57-4DC2-8F74-743BE6430083@microsoft.com...
    > Hi,
    >
    > I want to create a virtual directory when a user has filled a form on an
    > ASP.net page. It works well on my dev server, but when I try it on my
    > production server, it fails. I got this error:
    >
    > System.Runtime.InteropServices.COMException (0x80070005): Access is denied
    > at System.DirectoryServices.DirectoryEntry.Bind(Boole an throwIfFail)
    > at System.DirectoryServices.DirectoryEntry.Bind()
    > at System.DirectoryServices.DirectoryEntry.get_IsCont ainer()
    > at System.DirectoryServices.ChildEnumerator..ctor(Dir ectoryEntry
    > container)
    > at System.DirectoryServices.DirectoryEntries.GetEnume rator()
    >
    > This is my code:
    >
    > DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC");
    > int siteId = 1;
    > IEnumerator list = root.Children.GetEnumerator();
    > while (list.MoveNext() && !isFound)
    > {
    > DirectoryEntry e = (DirectoryEntry)list.Current;
    > if(e.SchemaClassName == "IIsWebServer")
    > {
    > string desc = (string)e.Invoke("Get","ServerComment");
    > if(desc == LIVESNAP_NAME)
    > {
    > siteId = Convert.ToInt32(e.Name);
    > isFound = true;
    > }
    > }
    > }
    >
    > I tried setting full control to everyone: It failed.
    > I tries impersonation with an admin account: it works
    > I tries impersonation with a power user acount: it works sometimes...
    >
    > How can have this to work without using an admin account? I think this is
    > not really secure to use an admin username an password in the web.config
    > file...
    >
    > Any idea?
    >
    > Thanks
    >
    > Stephane
    >

    Joe Kaplan \(MVP - ADSI\) Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139