Impersonate Thread with Domain ID in (ASP.NET)

B

bvasanth123

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()


Regards,
Vasanth
 
P

Paul Clement

On 5 Jul 2005 14:51:14 -0700, (e-mail address removed) wrote:

¤ 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
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top