Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8250975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:05:21+00:00 2026-06-08T00:05:21+00:00

Given the following method, I am trying to start/stop an IIS 7 app pool.

  • 0

Given the following method, I am trying to start/stop an IIS 7 app pool. I can successfully accomplish this on my local system, but when I put this on our Windows 2008 server, I get an error only when trying to stop the service – starting works fine:

[NoCache]
public ActionResult EnableAppPool(Models.ActionRequest actionRequest)
{
    try
    {
        if (ModelState.IsValid && actionRequest.ActionRequestPassword == ConfigurationManager.AppSettings["NewsfeedAdminPassword"])
        {
            bool enableNewsfeed = false;
            enableNewsfeed = Convert.ToBoolean(actionRequest.EnableNewsfeedAppPool);

            string sPath = "IIS://" + ConfigurationManager.AppSettings["MachineName"] + "/W3SVC/AppPools/" + ConfigurationManager.AppSettings["AppPoolName"];
            Console.WriteLine(sPath);
            DirectoryEntry w3svc = new DirectoryEntry(sPath);
            if (enableNewsfeed)
            {
                w3svc.Invoke("Start");
            }
            else
            {
                w3svc.Invoke("Stop");
            }
        }
    }
    catch (Exception ex)
    {
        throw ex;
    }

    return null;
}

The error is as follows:

Access is denied. (Exception from HRESULT: 0x80070005
(E_ACCESSDENIED)) Description: An unhandled exception occurred during
the execution of the current web request. Please review the stack
trace for more information about the error and where it originated in
the code.

Exception Details: System.UnauthorizedAccessException: Access is
denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request
identity. ASP.NET has a base process identity (typically
{MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and
the configured application pool identity on IIS 7.5) that is used if
the application is not impersonating. If the application is
impersonating via , the identity will be
the anonymous user (typically IUSR_MACHINENAME) or the authenticated
request user.

I realize this is a permissions issue, but I’m not sure about what I have to grant access to, and for what user.

FYI: I already enabled IIS 6 Metabase and WMI Compatibility

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:05:23+00:00Added an answer on June 8, 2026 at 12:05 am

    The identity under which you code is running does not have access to start and stop app pools. Here is a quote from an article

    “In order to communicate with Active Directory one must take into account network security, business rules, and technological constraints. If you’re using Active Directory code from an ASP.NET page you must ensure that the code has the appropriate level of permission to access and interact with the directory. For development purposes or proof of concept you can enable impersonation at the ASP.NET level (in web.config) and the IIS level and if the IIS server and the directory domain controller reside on the same machine this will work. However, if these entities are not co-located on the same server (as they never are in production) you can wrap the code around an impersonation class (such as the Zeta Impersonator which will execute the Directory calls under the token of the impersonated user.”

    http://www.codeproject.com/Articles/18102/Howto-Almost-Everything-In-Active-Directory-via-C#3

    And this article clearly expains how to run bits of code in you application under diff (posibliy higher level acess user) context.

    http://support.microsoft.com/kb/306158

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to accomplish the following in C#/.NET 2.0: Given an IPAddress object (say,
Given the following method signature, why is it when a parameter is explicitly named
Given the following two ways of defining a class method in Ruby: class Foo
Given the following situation (UML below), If Y has the method: public void PrintWs();
Given the following module, module Foo def bar :baz end end def send_to_foo(method) #
It seems that the following is a common method given in many tutorials on
I am trying to start/stop tomcat from Ant. Here is my relevant portion of
Given the following pieces of code, which one is more efficient? The real method
I'm trying to write a method for coverting a given object to an instance
The task I was trying to accomplish was that given an input pattern, e.g.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.