How can I debug a local IIS service with Visual Studio running as a non-Administrator user?
Asked Answered
K

4

14

I have installed Visual Studio 2008 and am running it as a non-Administrator user.

I have a Web Application project I am developing and would like to debug it using Visual Studio. I can compile and also debug with "Visual Studio Development Server" without problems. But, when I select "Use Local IIS Web server" in my project properties and try to save the project, Visual Studio gives me the error: "To access local IIS Web sites, you must run Visual Studio in the context of an administrator account."

Now, if I take Microsoft's word, I must run Visual Studio by actually using an administrative account, but Microsoft's ultimatums haven't always proven to be absolute.

From other similar questions, I've added my user to the "Debugger Users" group and given the user the SeDebugPrivilege privilege. But, I cannot "Run as Administrator" since my user is not actually an administrator.

Kenny answered 16/7, 2010 at 18:59 Comment(1)
I don't like to run Visual Studio as administrator either.Odometer
K
13

It looks like that for now, the answer is you can't.

I will delete this if a method or solution comes along.

Kenny answered 1/9, 2010 at 18:51 Comment(1)
The fact that VS2012 right now actively offers to restart as admin when you try is official confirmation of this remaining the case...Ayotte
W
2

You could use IIS Express which doesn't require admin privileges. Don't think there's a stand-alone download but you can get it as part of Web Matrix here: http://www.microsoft.com/web/webmatrix/download/

Wiles answered 16/7, 2010 at 19:2 Comment(1)
Interesting, but I think it's a Visual Studio issue in that it simply won't let me select the option to debug Local IIS.Kenny
U
1

I've never tried this, but it might be worth a shot.

While logged in as an administrator, you could change the identity under which the service and/or the application pools run. Make them run under the same non-administrator account you normally use. Then when Visual Studio attempts to attach to the process, the security context will match between the debugger and the process being debugged.

I think you'd only need to change the identity under which your application pool runs.

Here's some more detail from James Kovacs' Weblog: Debugging as a Non-Admin

Underrate answered 8/9, 2010 at 17:31 Comment(2)
Visual Studio actually gives me an error dialog, saying "To access local IIS Web sites, you must run Visual Studio in the context of an administrator account." So, the "security context" doesn't even matter; no matter which account under which I'm running the service, Visual Studio itself prevents me from selecting the account to debug IIS.Kenny
The problem is that even if you change identity of the IIS pool (changing worker process owner) then it still runs in session 0, not in user session.Gunner
A
0

Is there already a website created within IIS for your project? Writing to the IIS metabase does require admin access. If you setup the website as an admin you may be able to debug it as a non-admin. One thing to try/test is to just point IIS at your website's folder and get it running, then use Visual Studio to do a process attach to the w3wp process.

Abelmosk answered 8/9, 2010 at 0:46 Comment(1)
can you attach to w3wp by just running visual studio and attaching the debugger to the process?Abelmosk

© 2022 - 2024 — McMap. All rights reserved.