views:

1738

answers:

1

I know you can impersonate in web.config,

Is the exact same thing possible in app.config for a console application?

+3  A: 

Console apps already run in the context of the running user, so yes, this is the default behavior.

ASP.NET has this feature because the iis worker process is already running in the context of the ASPNET account, not the browsing user.

If you want to impersonate another specific user for some operation, you need to use the windows APIs. Here is a code sample (haven't tried this sample, but it looks good):

http://www.buro9.com/blog/2006/10/06/impersonating-a-user-in-c/

uosɐſ