asp.net Impersonate User for network resource access

Posted by lonelycoder on Stack Overflow See other posts from Stack Overflow or by lonelycoder
Published on 2010-04-15T15:26:09Z Indexed on 2010/04/16 0:13 UTC
Read the original article Hit count: 543

Filed under:
|
|

code:

System.Security.Principal.WindowsImpersonationContext impersonationContext;
impersonationContext =
    ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();

//access network resources.

impersonationContext.Undo();

web.config:

<authentication mode="Windows">       
</authentication>
<identity impersonate="true"
userName="user"
password="password"></identity>

As clear from web.config file, the app runs in an impersonated mode. I need to impersonate temporarily on top of that to access a network resource. I do that as shown above.

This works fine on server if I browse to the website on the local IE installed on the server but when I access the app from my PC or any other PC, I get a access denied.

Btw, this is all within an enterprise domain environment. so IE in both cases is passing a valid authenticated token.

Any ideas what is going on. thanks.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about iis