By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,683 Members | 1,398 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,683 IT Pros & Developers. It's quick & easy.

ASP.Net - Run external application as specific user

P: n/a
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!
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi Greg,

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

Regards,
Fergus
Nov 20 '05 #2

P: n/a
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
Nov 20 '05 #3

P: n/a
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?

"Fergus Cooney" <fi******@tesco.net> wrote in message news:<O1**************@TK2MSFTNGP10.phx.gbl>...
Hi Greg,

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

Regards,
Fergus

Nov 20 '05 #4

P: n/a
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
Nov 20 '05 #5

P: n/a
I finally got it. Using the link below, I added the impersonation
code as part of my procedure which is called by the thread.

http://support.microsoft.com/default...;en-us;Q306158

Thanks for you help.
"Fergus Cooney" <fi******@tesco.net> wrote in message news:<e1*************@TK2MSFTNGP10.phx.gbl>...
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

Nov 20 '05 #6

P: n/a
Way to go, Greg! ;-) Thanks for the link - I'll go learn myself something.
Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.