473,385 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Starting up Windows Program from a webform with current users's authentication

Suppose you have one domain, filled with a couple of users. What needs to be
done now is I need to start a windows application from a webform by pressing
a button on the webform (for example).

The problem is that the user who "owns" the service is always the ASPNET
account. That's not good since you don't see the actual application (because
it's owned by ASPNET). I've tried changed the processmodel section in the
machine.config file to "SYSTEM" instead of "MACHINE" but that didn't work.
It was the same thing except the process owner was now "SYSTEM" and should
be my logged on (authenticated) user. The reason why that is needed is
because the application detects the current users login and compares that
with the membership of a certain group.

My next step was to try impersonation, but that doesn't work yet. See
snippet of code below. I don't know what i do wrong but i keeps functioning
as the ASPNET account. I also tried giving the ASPNET account the rights of
("Act as a part of the operating system") but that does nothing again. What
am i missing here. Ah, in the web.conf impersonation is set to true but
still doesn't work.

Help would be strongly appreciated.
Kristof

System.Security.Principal.WindowsImpersonationCont ext impersonationContext;

impersonationContext =
((System.Security.Principal.WindowsIdentity)User.I dentity).Impersonate();

System.Diagnostics.Process myProcess = new System.Diagnostics.Process();

myProcess.StartInfo.FileName = "test.exe";

myProcess.StartInfo.WorkingDirectory = @"D:\test";

myProcess.Start();

impersonationContext.Undo();


Nov 18 '05 #1
4 2392
you need to turn anonymous off on the website. then set impersonation on in
the web config.

note: your windows app must be written to run without a window, or you will
get a permission error when it starts up, as access to the desktop will be
denied.

-- bruce (sqlwork.com)

"Kristof Despiere" <kr***************@despiere.be> wrote in message
news:c9**********@reader13.wxs.nl...
Suppose you have one domain, filled with a couple of users. What needs to be done now is I need to start a windows application from a webform by pressing a button on the webform (for example).

The problem is that the user who "owns" the service is always the ASPNET
account. That's not good since you don't see the actual application (because it's owned by ASPNET). I've tried changed the processmodel section in the
machine.config file to "SYSTEM" instead of "MACHINE" but that didn't work.
It was the same thing except the process owner was now "SYSTEM" and should
be my logged on (authenticated) user. The reason why that is needed is
because the application detects the current users login and compares that
with the membership of a certain group.

My next step was to try impersonation, but that doesn't work yet. See
snippet of code below. I don't know what i do wrong but i keeps functioning as the ASPNET account. I also tried giving the ASPNET account the rights of ("Act as a part of the operating system") but that does nothing again. What am i missing here. Ah, in the web.conf impersonation is set to true but
still doesn't work.

Help would be strongly appreciated.
Kristof

System.Security.Principal.WindowsImpersonationCont ext impersonationContext;
impersonationContext =
((System.Security.Principal.WindowsIdentity)User.I dentity).Impersonate();

System.Diagnostics.Process myProcess = new System.Diagnostics.Process();

myProcess.StartInfo.FileName = "test.exe";

myProcess.StartInfo.WorkingDirectory = @"D:\test";

myProcess.Start();

impersonationContext.Undo();

Nov 18 '05 #2
Did that (anonymous off and impersonation=true)
And it should be a windows application with window that should be started up
from the webform. The only problem is that it keeps starting up with the
wrong "user owner". Task Manager=>Processes keeps showing the "ASPNET" user
as the owner.
"bruce barker" <no***********@safeco.com> wrote in message
news:u8**************@tk2msftngp13.phx.gbl...
you need to turn anonymous off on the website. then set impersonation on in the web config.

note: your windows app must be written to run without a window, or you will get a permission error when it starts up, as access to the desktop will be
denied.

-- bruce (sqlwork.com)

"Kristof Despiere" <kr***************@despiere.be> wrote in message
news:c9**********@reader13.wxs.nl...
Suppose you have one domain, filled with a couple of users. What needs to
be
done now is I need to start a windows application from a webform by

pressing
a button on the webform (for example).

The problem is that the user who "owns" the service is always the ASPNET
account. That's not good since you don't see the actual application

(because
it's owned by ASPNET). I've tried changed the processmodel section in

the machine.config file to "SYSTEM" instead of "MACHINE" but that didn't work. It was the same thing except the process owner was now "SYSTEM" and should be my logged on (authenticated) user. The reason why that is needed is
because the application detects the current users login and compares that with the membership of a certain group.

My next step was to try impersonation, but that doesn't work yet. See
snippet of code below. I don't know what i do wrong but i keeps

functioning
as the ASPNET account. I also tried giving the ASPNET account the rights

of
("Act as a part of the operating system") but that does nothing again.

What
am i missing here. Ah, in the web.conf impersonation is set to true but
still doesn't work.

Help would be strongly appreciated.
Kristof

System.Security.Principal.WindowsImpersonationCont ext

impersonationContext;

impersonationContext =
((System.Security.Principal.WindowsIdentity)User.I dentity).Impersonate();
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();

myProcess.StartInfo.FileName = "test.exe";

myProcess.StartInfo.WorkingDirectory = @"D:\test";

myProcess.Start();

impersonationContext.Undo();


Nov 18 '05 #3
> The problem is that the user who "owns" the service is always the ASPNET
what service are you talking about?
machine.config file to "SYSTEM" instead of "MACHINE" but that didn't you are bumping the rights of everything on the server up a notch. This is
certainly not recommended.

you will first need to find out the identity that the web page is under. It
may not be what you think. Use this line of code to find out what identity
the process is running under. Once you find the correct identity, you can
either use impersonation to set the application to run under the proper
account or you can impersonate thru code. You will need to add the
appropriate rights on the directory housing the windows application. You
should configure it for read permissions by adding the identity to be
impersonated to the ACL.

Response.Write("<script>alert('"+System.Security.P rincipal.WindowsIdentity.GetCurrent().Name.ToStrin g()+"')</script>");
--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Kristof Despiere" <kr***************@despiere.be> wrote in message
news:c9**********@reader13.wxs.nl... Did that (anonymous off and impersonation=true)
And it should be a windows application with window that should be started
up
from the webform. The only problem is that it keeps starting up with the
wrong "user owner". Task Manager=>Processes keeps showing the "ASPNET"
user
as the owner.
"bruce barker" <no***********@safeco.com> wrote in message
news:u8**************@tk2msftngp13.phx.gbl...
you need to turn anonymous off on the website. then set impersonation on

in
the web config.

note: your windows app must be written to run without a window, or you

will
get a permission error when it starts up, as access to the desktop will
be
denied.

-- bruce (sqlwork.com)

"Kristof Despiere" <kr***************@despiere.be> wrote in message
news:c9**********@reader13.wxs.nl...
> Suppose you have one domain, filled with a couple of users. What needs to
be
> done now is I need to start a windows application from a webform by

pressing
> a button on the webform (for example).
>
> The problem is that the user who "owns" the service is always the
> ASPNET
> account. That's not good since you don't see the actual application

(because
> it's owned by ASPNET). I've tried changed the processmodel section in

the > machine.config file to "SYSTEM" instead of "MACHINE" but that didn't work. > It was the same thing except the process owner was now "SYSTEM" and should > be my logged on (authenticated) user. The reason why that is needed is
> because the application detects the current users login and compares that > with the membership of a certain group.
>
> My next step was to try impersonation, but that doesn't work yet. See
> snippet of code below. I don't know what i do wrong but i keeps

functioning
> as the ASPNET account. I also tried giving the ASPNET account the
> rights

of
> ("Act as a part of the operating system") but that does nothing again.

What
> am i missing here. Ah, in the web.conf impersonation is set to true
> but
> still doesn't work.
>
> Help would be strongly appreciated.
> Kristof
>
> System.Security.Principal.WindowsImpersonationCont ext

impersonationContext;
>
> impersonationContext =
> ((System.Security.Principal.WindowsIdentity)User.I dentity).Impersonate(); >
> System.Diagnostics.Process myProcess = new
> System.Diagnostics.Process();
>
> myProcess.StartInfo.FileName = "test.exe";
>
> myProcess.StartInfo.WorkingDirectory = @"D:\test";
>
> myProcess.Start();
>
> impersonationContext.Undo();
>
>
>
>



Nov 18 '05 #4
I meant thread instead of service. Ok time to go a bit more specific

When you customize MS CRM, you can add a button in for example the accounts
or contacts pages. But you can only assign url's to that button.
On the other hand i have a windows applications that uses windows
authentication to detect te permission etc.. of the logged on user (which
also deals with accounts/contacts/...)
The meaning is that when someone clicks the button in MS CRM, a url will be
openened (for example "http://testserver/test.aspx?accountID=334" or sth
like that). Then the webform should detect if the windows application is
open. If it is, just navigate to the proper record of the windows appl., if
the application is not active at the moment, it should start the application
(with authenticated user impersonation), and navigate to the right record.
But even when I include impersonation when I instantiate a
System.Diagnostics.Process (with impersonationContext) it start the windows
application with the "ASPNET" account. Since it's the wrong account, the
application won't show up since it needs to be started up with the current
user.
Thanx for the help btw :p
The last things you said i need to check out, I've detected that part
"System.Security.Principal.WindowsIdentity.GetCurr ent().Name.ToString()" by
inputting it in a textbox on the page on Page_Load. I shows the right user
"DOMAIN/USERNAME" (So that should be OK too)
About that :
Once you find the correct identity, you can
either use impersonation to set the application to run under the proper
account or you can impersonate thru code. You will need to add the
appropriate rights on the directory housing the windows application. You
should configure it for read permissions by adding the identity to be
impersonated to the ACL. Should take a look, probably that or not :p I'll get back to you once i've
tried

Kristof

PS :> > machine.config file to "SYSTEM" instead of "MACHINE" but that didn't you are bumping the rights of everything on the server up a notch. This is
certainly not recommended. I've turned that back to machine since i didn't help anyway :p
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:u%****************@tk2msftngp13.phx.gbl...
The problem is that the user who "owns" the service is always the ASPNET

what service are you talking about?
machine.config file to "SYSTEM" instead of "MACHINE" but that didn't

you are bumping the rights of everything on the server up a notch. This is
certainly not recommended.

you will first need to find out the identity that the web page is under.

It may not be what you think. Use this line of code to find out what identity
the process is running under. Once you find the correct identity, you can
either use impersonation to set the application to run under the proper
account or you can impersonate thru code. You will need to add the
appropriate rights on the directory housing the windows application. You
should configure it for read permissions by adding the identity to be
impersonated to the ACL.

Response.Write("<script>alert('"+System.Security.P rincipal.WindowsIdentity.G
etCurrent().Name.ToString()+"')</script>");

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Kristof Despiere" <kr***************@despiere.be> wrote in message
news:c9**********@reader13.wxs.nl...
Did that (anonymous off and impersonation=true)
And it should be a windows application with window that should be started
up
from the webform. The only problem is that it keeps starting up with the
wrong "user owner". Task Manager=>Processes keeps showing the "ASPNET"
user
as the owner.
"bruce barker" <no***********@safeco.com> wrote in message
news:u8**************@tk2msftngp13.phx.gbl...
you need to turn anonymous off on the website. then set impersonation on
in
the web config.

note: your windows app must be written to run without a window, or you

will
get a permission error when it starts up, as access to the desktop will
be
denied.

-- bruce (sqlwork.com)

"Kristof Despiere" <kr***************@despiere.be> wrote in message
news:c9**********@reader13.wxs.nl...
> Suppose you have one domain, filled with a couple of users. What
needs to
be
> done now is I need to start a windows application from a webform by
pressing
> a button on the webform (for example).
>
> The problem is that the user who "owns" the service is always the
> ASPNET
> account. That's not good since you don't see the actual application
(because
> it's owned by ASPNET). I've tried changed the processmodel section in

the
> machine.config file to "SYSTEM" instead of "MACHINE" but that didn't

work.
> It was the same thing except the process owner was now "SYSTEM" and

should
> be my logged on (authenticated) user. The reason why that is needed

is > because the application detects the current users login and compares

that
> with the membership of a certain group.
>
> My next step was to try impersonation, but that doesn't work yet. See
> snippet of code below. I don't know what i do wrong but i keeps
functioning
> as the ASPNET account. I also tried giving the ASPNET account the
> rights
of
> ("Act as a part of the operating system") but that does nothing again. What
> am i missing here. Ah, in the web.conf impersonation is set to true
> but
> still doesn't work.
>
> Help would be strongly appreciated.
> Kristof
>
> System.Security.Principal.WindowsImpersonationCont ext
impersonationContext;
>
> impersonationContext =
>

((System.Security.Principal.WindowsIdentity)User.I dentity).Impersonate();
>
> System.Diagnostics.Process myProcess = new
> System.Diagnostics.Process();
>
> myProcess.StartInfo.FileName = "test.exe";
>
> myProcess.StartInfo.WorkingDirectory = @"D:\test";
>
> myProcess.Start();
>
> impersonationContext.Undo();
>
>
>
>



Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Bob Everland | last post by:
I have an application that is ISAPI and the only way to secure it is through NT permissions. I need to have a way to login to windows authentication so that when I get to the ISAPI application no...
4
by: Nick | last post by:
I'm developing an intranet app, and want to get the current user name for logging purposes. I've turned off anonymous access, and turned on windows authentication in the IIS config. The apps...
8
by: Raj Thakkar | last post by:
Hi, I am currenty working on a site for intranet. I have a user control in the header of every page that will be displayed only if people with certain username are surfing the site. These lists...
6
by: Kevin Yu | last post by:
is it possible to for user to click a logout button to logout and when the user want to get into the system again, the user have to login again? Kevin
3
by: serge calderara | last post by:
Dear all, I clearly underdand the advantage of both type of authentification but is it allowed or possible to set the Authentication mode to Windows and then handle a login form for defined...
8
by: Keith H | last post by:
I'm looking for a way to force the user to re-authenticate with their Windows username/password/domain after clicking the submit button on an ASP.NET page. This is for an internal application. ...
3
by: sefe dery | last post by:
hi ng, i try to create a asp.net 1.0 website on windows server 2003(Servername: ServerX) with iis 6.0. PROBLEM: The user should login with his windows credentials in basic.aspx and...
3
by: Chris Paul | last post by:
I'm having trouble with PHP & PostgreSQL/OpenLDAP/Apache on Windows. I've set this up countless times on BSD (piece of cake) but I'm trying to do this on Windows now so that my developer can work...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.