ASP.Net - Run external application as specific user

G

Greg

Here's the situation.

I have an asp.net application that calls a console application which
copies files between servers. I have the console application because
the copying of files takes a while and don't want the asp.net app to
wait until its finished. So the user clicks on a button within the
asp.net app and I'm using the Shell command to call the console app.

I've tried using impersonate within the asp.net application but it
looses the info when the console application is called. If I run the
console app but its self, away from the asp.net app, it runs fine
which leads me to believe the console app is running under the aspnet
userid which doesn't have access to the servers.

Questions
1. Is there a way to run the console application as a different user?
2. Can I connect to a UNC in the console application as a specific
user preferrable without mapping a drive?

Any help is greatly appreciated.

Thanks!
 
F

Fergus Cooney

Hi Greg,

Would doing your file transfer in a separate Thread but still within your
asp.net app be of any use?

Regards,
Fergus
 
C

Cor

Greg,
I think that this needs a windows service.

Although it sounds strange, it sounds as an unmanaged proces, what happens
by instance when the user send twice?
But that is your problem of course.

Giving the control over to another user than the asp.user will give I think
(when you get it working with another user) maybe problems again in future
because of a "maybe" security patch from Microsoft.
Just a thougth
Cor
 
G

Greg

Fergus,

I've never used threads before but from looking at it today, it seems
to be the good choice. But I still can't get it working. Here is the
code I'm using.

Dim myThread As New System.Threading.Thread(AddressOf Transfer)
myThread.Start()

The process still doesn't have access to the servers. But if I call
Transfer directly without going thru the new thread, it works. So it
still appears the new thread isn't using the impersonate user.

Hopefully there is a way to set the user for the thread but I haven't
found it yet. Any ideas?
 
F

Fergus Cooney

Hi Greg,

I'm afraid I've done nothing in the way of users and impersonation (I only
have a vague idea what this actually means).

You're saying that the impersonation works in the App but not in a new
Thread? This surprises me as my understanding is that Threads are supposed to
share whatever else is going on within the AppDomain. However, my knowledge
<is> scanty.

I wish I could help further. :-(

Regards,
Fergus
 

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

Top