Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > Problem starting windows forms application from ASP.Net 2.0

Reply
Thread Tools

Problem starting windows forms application from ASP.Net 2.0

 
 
Quille
Guest
Posts: n/a
 
      08-27-2006
Hi !

I'm having trouble starting desktop windows forms application with gui.
So far i have managed to make it run when I access website on local
computer,
trying to start application from any other machine fails.

I have modified machine.config process model as follows:
<processModel autoConfig="true" userName="SYSTEM" password="AutoGenerate" />

Now aspnet worker process is running under SYSTEM account.

Im using Windows authentication and Im impersonating currently logged user
so my web config contains:
<authentication mode="Windows" />
<identity impersonate="true" />

Platform is Windows XP and User is automatically logged in to desktop.

Code for starting process is below...

Please tell me what am I doing wrong, point me in right direction, thank you
!

Goran


Code:
private bool NativeProcessStart()
{
string locError = string.Empty;
// Impersonation constants
const uint GENERIC_ALL = 0x10000000;
const int SecurityImpersonation = 2;
const int TokenType = 1;
IntPtr Token = new IntPtr(0);
IntPtr DupedToken = new IntPtr(0);
bool ret;

// Init sceurity attribures struct
SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES();
sa.bInheritHandle = false;
sa.Length = Marshal.SizeOf(sa);
sa.lpSecurityDescriptor = (IntPtr)0;

// Get Impersonated user token
Token = WindowsIdentity.GetCurrent().Token;
// Duplicate Impersonated user token
ret = DuplicateTokenEx(Token,GENERIC_ALL,ref
sa,SecurityImpersonation,TokenType,ref DupedToken);
if (false == ret)
{
return ret;
}

STARTUPINFO si = new STARTUPINFO();
si.cb = Marshal.SizeOf(si);
si.lpDesktop = "";
PROCESS_INFORMATION pi = new PROCESS_INFORMATION();

ret = CreateProcessAsUser(DupedToken, null,
this._playerPath + " " + this._playerParams, ref sa, ref sa, false, 0,
(IntPtr)0,
System.IO.Path.GetDirectoryName(this._playerPath), ref si,out pi);

if (false == ret)
{
return ret;
}

CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
ret = CloseHandle(DupedToken);
return ret;
}


 
Reply With Quote
 
 
 
 
MikeS
Guest
Posts: n/a
 
      08-27-2006
So you are trying to run a windows forms application right there on the
web server for a user who is visiting your site?

Or is all that CreateProcessAsUser code supposed to go over the network
and start a process on their PC?

How is it that running your web app as SYSTEM and starting up programs
on other peoples PC's from a web server is a good idea?

I think one way to give them a windows forms app to run is to use
"click once deployment" and publish that app to the web server.

http://msdn2.microsoft.com/en-us/library/t71a733d.aspx

 
Reply With Quote
 
 
 
 
Quille
Guest
Posts: n/a
 
      08-27-2006
Hi !
Thanks for fast response ...

"MikeS" <> wrote in message
news: ups.com...
> So you are trying to run a windows forms application right there on the
> web server for a user who is visiting your site?
>


I'm trying to make web interface for windows forms application similar to
Mediaportal and it's web interface....


> Or is all that CreateProcessAsUser code supposed to go over the network
> and start a process on their PC?
>

No just on PC hosting web.

> How is it that running your web app as SYSTEM and starting up programs
> on other peoples PC's from a web server is a good idea?
>

No this is not good ides and it is not my intention ...

> I think one way to give them a windows forms app to run is to use
> "click once deployment" and publish that app to the web server.
>
> http://msdn2.microsoft.com/en-us/library/t71a733d.aspx
>


I'm not trying to distribute application over web, im just traing to control
it over web

Thnaks for comments once again,

Goran


 
Reply With Quote
 
MikeS
Guest
Posts: n/a
 
      08-27-2006
OK, well if it is all going to run client side, then why not run it all
client side, controls and or code in the browser not on the server.

For example:

http://www.15seconds.com/issue/030610.htm

Then you might just use Process.Start without needing impersonation.

>From a Full Trust site, this works for me...


<object id="UserControl1"
classid="http:WindowsControlLibrary1.dll#WindowsCo ntrolLibrary1.UserControl1"
height="0" width="0"> </object>

Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim psi As New ProcessStartInfo("calc.exe")
Process.Start(psi)
End Sub

 
Reply With Quote
 
Quille
Guest
Posts: n/a
 
      08-28-2006
Hi again !

"MikeS" <> wrote in message
news: oups.com...
> OK, well if it is all going to run client side, then why not run it all
> client side, controls and or code in the browser not on the server.
>


Actaully I'm trying to make folowing scenarios to work:
1.) Machine (Server) running program ("Player") similar to powerpoint that
uses managed directx for display that software is controled using asp.net
web site and remoting.
In this scenario user can open "Player" on one monitor and IE containig UI
on another monitor.
In this scenario I'm able to start player from web ui and everything works
fine

2.) Machine (Server) running "Player" and Machine(Client) running IE
containing UI for Player
In this scenario I can't start player from web UI and I would like to make
it possible...

Anyway thanks for comments...

> For example:
>
> http://www.15seconds.com/issue/030610.htm
>
> Then you might just use Process.Start without needing impersonation.
>
>>From a Full Trust site, this works for me...

>
> <object id="UserControl1"
> classid="http:WindowsControlLibrary1.dll#WindowsCo ntrolLibrary1.UserControl1"
> height="0" width="0"> </object>
>
> Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Dim psi As New ProcessStartInfo("calc.exe")
> Process.Start(psi)
> End Sub
>


Goran


 
Reply With Quote
 
MikeS
Guest
Posts: n/a
 
      08-28-2006
OK, I see, I am thick.

That's a good question.

So will someone be logged into the web server all the time, will there
be an interactive session open?

 
Reply With Quote
 
Quille
Guest
Posts: n/a
 
      08-29-2006
Hi again!

"MikeS" <> wrote in message
news: ups.com...
> OK, I see, I am thick.
>
> That's a good question.
>
> So will someone be logged into the web server all the time, will there
> be an interactive session open?
>


Yes "server" will perform automatic logon, this is acutally must, because I
don't think I can force start of
windows forms application before some one is logged to console.

Thanks,
Goran


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
3 ESSENTIAL TOOLS FOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLSFOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLS FOR STARTING ANDMAINTAINING... Oanh Bui C++ 0 04-27-2009 12:51 PM
3 ESSENTIAL TOOLS FOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLSFOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLS FOR STARTING ANDMAINTAINING... Oanh Bui C Programming 0 04-27-2009 12:51 PM
3 ESSENTIAL TOOLS FOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLSFOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLS FOR STARTING ANDMAINTAINING... Oanh Bui Python 0 04-27-2009 12:46 PM
Starting a GUI application out of an console application Fabian Steiner Python 1 07-17-2006 05:01 PM
forms authentication -- expired forms cookie vs. not provided forms cookie Eric ASP .Net Security 2 01-27-2006 10:09 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57