Ask a Question related to ASP.NET Security, Design and Development.
-
jyjohnson #1
need clear example of threading + impersonation
My asp.net application needs to allow the user (via basic authentication) to
execute a long running process (new thread) that writes files out to a share
on another server.
This works if I just use impersonation without creating a new thread. I'm
using XP Pro + IIS 5. I think I have access to a Win 2003 server if that
makes things easier.
Thanks....
jyjohnson Guest
-
Threading within a service
Hi there, I hope someone can help me. I have a client app. being used by about 50 users. When thy open the app, it calls a webservice on a... -
no neutral threading in win 2003?
Hi All, I have a COM component written in C++ which is inteneded to be stored in the Application object. This means of course that I had to write... -
Threading model to 'Any Apartment'
Hey guys, i am relatively new to this COM+ thing, i am trying to figure out where do i set the threading model for my application as 'any... -
Threading and Session Objects
Hi, I´m doing an asp.net application that uploads and downloads files and folders between the client and the server on my intranet. To do this I... -
Threading / sockets bug
Where do I report this bug? Only happens on windows platform: causes some error ot lock that doesnt occur on Unices require \'socket\'... -
Dominick Baier [DevelopMentor] #2
Re: need clear example of threading + impersonation
Hello jyjohnson,
i assume that you first impersonate and start the thread afterwards....
impersonation tokens are not copied to new threads in .net 1.1 (they will
in 2.0)
do it like this
start the thread
impersonate the user on the new thread
something like (only compiled in the newsreader :)
Worker worker = new Worker();
worker.user = Page.User;
Thread t = new Thread(new ThreadStart(worker.DoWork);
class Worker
{
public WindowsPrincipal user;
public void DoWork()
{
WindowsImpersonationContext ctx;
try
{
user.Impersonate();
}
finally
{
ctx.Undo();
}
}
}
---------------------------------------
Dominick Baier - DevelopMentor
[url]http://www.leastprivilege.com[/url]
> My asp.net application needs to allow the user (via basic
> authentication) to execute a long running process (new thread) that
> writes files out to a share on another server.
>
> This works if I just use impersonation without creating a new thread.
> I'm using XP Pro + IIS 5. I think I have access to a Win 2003 server
> if that makes things easier.
>
> Thanks....
>
Dominick Baier [DevelopMentor] Guest
-
jyjohnson #3
Re: need clear example of threading + impersonation
I think I've tried that.... I've tried many code snips, etc, ! I understand
the problem (i.e., new threads use the aspnet account identity, not the
impersonated identity)...
I get an error on this line ---> user.Impersonate 'not a member of
WindowsPrinciple
Thanks!
"Dominick Baier [DevelopMentor]" wrote:
> Hello jyjohnson,
>
> i assume that you first impersonate and start the thread afterwards....
>
> impersonation tokens are not copied to new threads in .net 1.1 (they will
> in 2.0)
>
> do it like this
>
> start the thread
> impersonate the user on the new thread
>
> something like (only compiled in the newsreader :)
>
>
> Worker worker = new Worker();
> worker.user = Page.User;
>
> Thread t = new Thread(new ThreadStart(worker.DoWork);
>
> class Worker
> {
> public WindowsPrincipal user;
>
> public void DoWork()
> {
> WindowsImpersonationContext ctx;
> try
> {
> user.Impersonate();
> }
> finally
> {
> ctx.Undo();
> }
> }
> }
>
>
> ---------------------------------------
> Dominick Baier - DevelopMentor
> [url]http://www.leastprivilege.com[/url]
>>> > My asp.net application needs to allow the user (via basic
> > authentication) to execute a long running process (new thread) that
> > writes files out to a share on another server.
> >
> > This works if I just use impersonation without creating a new thread.
> > I'm using XP Pro + IIS 5. I think I have access to a Win 2003 server
> > if that makes things easier.
> >
> > Thanks....
> >
>
>
>jyjohnson Guest



Reply With Quote

