Visual Studio Development Bookmark and Share   
 index > Visual Studio Debugger > Impersonation is ignored when debugging a WebService (VS 2005/.net 2)
 

Impersonation is ignored when debugging a WebService (VS 2005/.net 2)

Hi,

We're developing a Soap WebService that is using remote files.

We added the required statement in its Web.Config file to impersonate from local "myComputer\ASPNET" to domain authorized "myDomain\myAccount" (ie <identity impersonate="true" userName="myDomain\myAccount" password="keepItSecret"/>). We'll improve this later (with no password in plain text file).

The webservice DLL works fine outside VS 2005 debugger.
However, when debugging, it reverts to myComputer\ASPNET (or ignores the Web.Config).

As far as I understand the debugger plumbing, it doesn't use the "regular" IIS WebService DLL when stepping inside. Instead it uses a hidden copy which could ignore the regular DLL configuration or even IIS virtual directories configuration since all my attempts to set impersonation through IIS GUI failed.

How could we get impersonation AND debugging ?
We're using W2K/SP 4 and IIS 5.

Thanks in advance for any help,

Hubert
hle3  Wednesday, March 15, 2006 9:25 PM

I am not able to repro.

Can you talk more about what you are doing?

- How are you determining the user name (System.Environment.UserName or something else?)

- Does this repro only when debug=true is set in web.config, or only when running under the debugger?

- If you need to be running under the debugger, how are you attaching the debugger?

- Do you have an IIS web project, or a file system web project?

BTW: When debugging, the regular old web service dll is used. Setting debug=true causes your code to be compiled with optimizations disabled, and causes PDBs (symbol databases) to be generated by the compiler.

Gregg Miskelly  Thursday, March 16, 2006 12:05 AM

Can you talk more about what you are doing ?

We're using C++/CLI with mixed assembly (with Common Language Runtime Support (/clr) option since we use some legacy ISO compiledC++ code).

Our application is a satellite imagery Catalog system using Oracle anda GIS software to access a fewterabytes of pictures.

It works fine till it tries to access the pictures on a remote computer since xxx\ASPNET is a local user.

- How are you determining the user name (System.Environment.UserName or something else?)

System::Security::Principal::WindowsIdentity::GetCurrent()->Name

- Does this repro only when debug=true is set in web.config, or only when running under the debugger?

Just under the debugger, debug=true does not matter.

- If you need to be running under the debugger, how are you attaching the debugger?

We launch the client and step into the server DLL.

BTW: When debugging, the regular old web service dll is used. Setting debug=true causes your code to be compiled with optimizations disabled, and causes PDBs (symbol databases) to be generated by the compiler.

We're sure that several instances of the webservice DLL are loaded concurrently. Each instance creates a specific log file and rings at startup and on termination. Since at least 2 log files are active at the same timeand we hear the startup sound each time we debug the DLLwe suppose IIS one is not the only one ... !?

Thanks for your interest,

Hubert

hle3  Thursday, March 16, 2006 8:36 AM

I have played around with this some more, but I am still not able to repro the problem.

If this is blocking you, you might want to consider calling PSS. We might need to get a debugger attached to really figure this one out.

If you want to keep working with me, here are my next follow ups:

1. Are you able to repro the problem on a 'hello world' web service? For example, this is what I tried:

- Create the new default C# web service in the IDE
- Start debugging the web service to make sure that everything is good
- Add this to my web.config
<identity impersonate ="true" userName="greggm3\foo" password=###/>
- Change my service to spit out the current identity using System.Security.Principal.WindowsIdentity.GetCurrent().Name
- Create a new C# console application
- Add a web reference to my service
- Write some code to invoke the HelloWorld method of my service
- Start debugging the client app
- Step into the call to the service

2. If you manually attach to the web server (aspnet_wp.exe/w3wp.exe), set a breakpoint in the service, and then run your web service client outside the debugger, does the problem go away?

Gregg Miskelly  Wednesday, March 22, 2006 1:44 AM
I have been having what sounds like a similar problem.

When I run my web application under the Visual Studio 2005 debugger, Environment.UserName returns "SYSTEM" (at some points in the code, but not at others).

When I run the application outside of Visual Studio (http://localhost/appname), impersonation works okay and Environment.UserName returns my actual username.

Oh well.. just seems like a sporadic bug to me..

Shannon Wagner  Tuesday, October 06, 2009 9:23 PM

You can use google to search for other answers

Custom Search

More Threads

• Howto map a custom HRESULT code to a particular message when an exception occured ?
• AppVerifier, WinDbg and VB6 Exceptions
• how to make VS 2005 a default JIT debugger?
• VIsual Studio Javascript Debuggin
• Is possible to get the value of parameter from mini dump file for managed code?
• Breakpoint will not currently be hit. No symbols loaded for this document.
• VS2005 Debugging, without Debugging and Release File
• asp.net web application keeps freezing and becomes unresponsive
• A First change exception of type ... but WHERE ???
• unhandled win32 exceptons