Groups | Blog | Home
all groups > asp.net security > july 2005 >

asp.net security : Impersonate Thread with Domain ID in (ASP.NET)


bvasanth123 NO[at]SPAM rediffmail.com
7/5/2005 2:51:14 PM
Hi
I am running the ASP.NET web application which is running under domain
id USER1. My OS is XP. I had added the following location tag in
machine.config to make my application run under USER1.
</location>
<location path=3D"Default Web Site/WebApplication1">
<system.web>
<identity impersonate=3D"true"
userName=3D"mydomain\USER1"
password=3D"mypassword"/>
</system.web>
</location>


In aspx page, I am displaying windows identity, which displays
mydomain\USER1 as expected.
When I start a new thread from aspx page, thread does not assume anu
identity. I would like to run the new thread under same identity (i.ed
mydomain\USER1). How can I do this impersonation on the thread?. I
tried impersonate() method (see code below), and got error "unable to
impersonate". (variable global.ApplicationIdentity is mydomain\USER1).
Please help
Dim newprin As WindowsPrincipal =3D New
WindowsPrincipal(Global.Applic=ADationIdentity)
Thread.CurrentPrincipal =3D newprin


Dim wi As WindowsImpersonationContext =3D
Global.ApplicationIdentity.Imp=ADersonate()


TryFileAccess()=20
wi.Undo()=20


Regards,=20
Vasanth
Paul Clement
7/6/2005 7:59:47 AM
[quoted text, click to view]

¤ Hi
¤ I am running the ASP.NET web application which is running under domain
¤ id USER1. My OS is XP. I had added the following location tag in
¤ machine.config to make my application run under USER1.
¤ </location>
¤ <location path="Default Web Site/WebApplication1">
¤ <system.web>
¤ <identity impersonate="true"
¤ userName="mydomain\USER1"
¤ password="mypassword"/>
¤ </system.web>
¤ </location>
¤
¤
¤ In aspx page, I am displaying windows identity, which displays
¤ mydomain\USER1 as expected.
¤ When I start a new thread from aspx page, thread does not assume anu
¤ identity. I would like to run the new thread under same identity (i.ed
¤ mydomain\USER1). How can I do this impersonation on the thread?. I
¤ tried impersonate() method (see code below), and got error "unable to
¤ impersonate". (variable global.ApplicationIdentity is mydomain\USER1).
¤ Please help
¤ Dim newprin As WindowsPrincipal = New
¤ WindowsPrincipal(Global.Applic­ationIdentity)
¤ Thread.CurrentPrincipal = newprin
¤
¤
¤ Dim wi As WindowsImpersonationContext =
¤ Global.ApplicationIdentity.Imp­ersonate()
¤
¤
¤ TryFileAccess()
¤ wi.Undo()

See if the following helps:

A System.Security.SecurityException exception occurs when you try to impersonate a user from a
secondary thread in an ASP.NET Web application
http://support.microsoft.com/default.aspx?scid=kb;en-us;842790


Paul
~~~~
AddThis Social Bookmark Button