Access to application pool denied Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)

-1

I made a console application which check if a application pool is stopped and if it is, then start it.

try {   
    using (Microsoft.Web.Administration.ServerManager mgr1 = new Microsoft.Web.Administration.ServerManager()){
        ApplicationPool appPool = mgr1.ApplicationPools[applicationPool];
            if (appPool != null)
                if (appPool.State == ObjectState.Stopped)
                    result = appPool.Start();
    }
} 
catch (Exception ex){}

When I run it as administrator, it works, otherwise I got this error:

Exception e: Access Denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) innerException: stacktrace: in System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
in System.DirectoryServices.DirectoryEntry.Bind() in System.DirectoryServices.DirectoryEntry.get_NativeObject() in System.DirectoryServices.DirectoryEntry.InvokeGet(String propertyName)

I tried the following solutions

https://docs.microsoft.com/it-it/windows/desktop/WmiSdk/wmi-troubleshooting

Cannot read configuration file due to insufficient permissions

Cannot read configuration file due to insufficient permissions

Access is denied when creating virtual directory

but nothing works

I need to run it without admin privileges

I use windows 10

c#
iis
permissions
application-pool
asked on Stack Overflow Jan 14, 2019 by r75

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0