473,382 Members | 1,078 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,382 software developers and data experts.

problem with aspnet "impersonation"

HI there,

I am developing a client side app which requires me to launch another
program when a user clicks a button on a web page. I thought I'd create
an asp.net page (using c# ) to accomplish this. After much research I
found that it's not that simple. The asp process runs under an aspnet
user, which does not let me launch my program. I ran accross some code
that is supposed to impersonate the logged in user, but I get the
following error:
"An anonymous identity cannot perform an impersonation"
The web.config file contains the following:

<identity impersonate="true" />

and the code in the asp.net page:

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
System.Security.Principal.WindowsImpersonationCont ext
impersonationContext;

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

System.Diagnostics.Process.Start("notepad.exe")

impersonationContext.Undo();
}
any ideas on how I can get around this?
Thanks!

Jorge
Nov 16 '05 #1
5 7379
You need to force the ASP.NET context to run under a specific identity that
has that privilege (impersonation is a specific right that not all accounts
have).

Still, launching EXEs from ASP pages is not such a good idea.
--
Klaus H. Probst, MVP
http://www.vbbox.com/

"hellrazor" <jo***@another-world.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
HI there,

I am developing a client side app which requires me to launch another
program when a user clicks a button on a web page. I thought I'd create
an asp.net page (using c# ) to accomplish this. After much research I
found that it's not that simple. The asp process runs under an aspnet
user, which does not let me launch my program. I ran accross some code
that is supposed to impersonate the logged in user, but I get the
following error:
"An anonymous identity cannot perform an impersonation"
The web.config file contains the following:

<identity impersonate="true" />

and the code in the asp.net page:

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
System.Security.Principal.WindowsImpersonationCont ext
impersonationContext;

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

System.Diagnostics.Process.Start("notepad.exe")

impersonationContext.Undo();
}
any ideas on how I can get around this?
Thanks!

Jorge

Nov 16 '05 #2
Exactly where such idea from!
PAtrick

"Klaus H. Probst" wrote:
You need to force the ASP.NET context to run under a specific identity that
has that privilege (impersonation is a specific right that not all accounts
have).

Still, launching EXEs from ASP pages is not such a good idea.
--
Klaus H. Probst, MVP
http://www.vbbox.com/

"hellrazor" <jo***@another-world.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
HI there,

I am developing a client side app which requires me to launch another
program when a user clicks a button on a web page. I thought I'd create
an asp.net page (using c# ) to accomplish this. After much research I
found that it's not that simple. The asp process runs under an aspnet
user, which does not let me launch my program. I ran accross some code
that is supposed to impersonate the logged in user, but I get the
following error:
"An anonymous identity cannot perform an impersonation"
The web.config file contains the following:

<identity impersonate="true" />

and the code in the asp.net page:

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
System.Security.Principal.WindowsImpersonationCont ext
impersonationContext;

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

System.Diagnostics.Process.Start("notepad.exe")

impersonationContext.Undo();
}
any ideas on how I can get around this?
Thanks!

Jorge


Nov 16 '05 #3
you have several problems

1) to do impersonation the asp.net account must have the "act as part of os"
permission
2) System.Diagnostics.Process.Start will start the process with the current
process id (asp.net) not the current thread identity anyway, so you don't
need above. look at the windows CreateProcessAsUser as support for this is
not in .net.
3) System.Diagnostics.Process.Start("notepad.exe") - notepad will fail
because it will try to open a window, not notmally allowed from a service.

-- bruce (sqlwork.com)

"hellrazor" <jo***@another-world.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
| HI there,
|
| I am developing a client side app which requires me to launch another
| program when a user clicks a button on a web page. I thought I'd create
| an asp.net page (using c# ) to accomplish this. After much research I
| found that it's not that simple. The asp process runs under an aspnet
| user, which does not let me launch my program. I ran accross some code
| that is supposed to impersonate the logged in user, but I get the
| following error:
|
|
| "An anonymous identity cannot perform an impersonation"
|
|
| The web.config file contains the following:
|
| <identity impersonate="true" />
|
| and the code in the asp.net page:
|
| private void Page_Load(object sender, System.EventArgs e)
| {
| // Put user code to initialize the page here
| System.Security.Principal.WindowsImpersonationCont ext
| impersonationContext;
|
| impersonationContext =
| ((System.Security.Principal.WindowsIdentity)User.I dentity).Impersonate();
|
| System.Diagnostics.Process.Start("notepad.exe")
|
| impersonationContext.Undo();
| }
|
|
| any ideas on how I can get around this?
|
|
| Thanks!
|
| Jorge
Nov 16 '05 #4
"bruce barker" <no***********@safeco.com> wrote in
news:u3**************@TK2MSFTNGP12.phx.gbl:
you have several problems

1) to do impersonation the asp.net account must have the "act as part
of os" permission
2) System.Diagnostics.Process.Start will start the process with the
current process id (asp.net) not the current thread identity anyway,
so you don't need above. look at the windows CreateProcessAsUser as
support for this is not in .net.
3) System.Diagnostics.Process.Start("notepad.exe") - notepad will fail
because it will try to open a window, not notmally allowed from a
service.

-- bruce (sqlwork.com)

"hellrazor" <jo***@another-world.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
| HI there,
|
| I am developing a client side app which requires me to launch another
| program when a user clicks a button on a web page. I thought I'd
| create an asp.net page (using c# ) to accomplish this. After much
| research I found that it's not that simple. The asp process runs
| under an aspnet user, which does not let me launch my program. I ran
| accross some code that is supposed to impersonate the logged in user,
| but I get the following error:
|
|
| "An anonymous identity cannot perform an impersonation"
|
|
| The web.config file contains the following:
|
| <identity impersonate="true" />
|
| and the code in the asp.net page:
|
| private void Page_Load(object sender, System.EventArgs e)
| {
| // Put user code to initialize the page here
| System.Security.Principal.WindowsImpersonationCont ext
| impersonationContext;
|
| impersonationContext =
| ((System.Security.Principal.WindowsIdentity)User.I dentity).Impersonate
| ();
|
| System.Diagnostics.Process.Start("notepad.exe")
|
| impersonationContext.Undo();
| }
|
|
| any ideas on how I can get around this?
|
|
| Thanks!
|
| Jorge


Thanks.

It's a local intranet app, so that's why I need to launch the .exe ...
The requirement is that the application needs to launch when a user
clicks a button on the webpage :0|
Nov 16 '05 #5
You have basically two problems to solve here.
1. You are trying to launch a program at the server side right? What kind of
program is it, does it have a UI. If the answer is yes, just forget it, this
will not work. If it's a pure non UI application not requiring a users
profile to be loaded, go on with 2.
2. Impersonate. Your asp.net runs in an impersonated security context of an
anonymous user. This identity cannot impersonate (why would it, it's already
impersonating).
What you should do is run your asp.net worker process using a fixed identity
with privileges to launch another program and turn off 'identity
impersonate' in your config file.

Willy.

"hellrazor" <jo***@another-world.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
HI there,

I am developing a client side app which requires me to launch another
program when a user clicks a button on a web page. I thought I'd create
an asp.net page (using c# ) to accomplish this. After much research I
found that it's not that simple. The asp process runs under an aspnet
user, which does not let me launch my program. I ran accross some code
that is supposed to impersonate the logged in user, but I get the
following error:
"An anonymous identity cannot perform an impersonation"
The web.config file contains the following:

<identity impersonate="true" />

and the code in the asp.net page:

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
System.Security.Principal.WindowsImpersonationCont ext
impersonationContext;

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

System.Diagnostics.Process.Start("notepad.exe")

impersonationContext.Undo();
}
any ideas on how I can get around this?
Thanks!

Jorge

Nov 16 '05 #6

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

Similar topics

0
by: Peter Afonin | last post by:
Hello: When I try to access a SQL server or a network share from an ASP.Net application that I run on my computer, I run into security problems (for instance, I cannot execute DTS package using...
1
by: Edward Yang | last post by:
I setup web.config with impersonation="true". On our local server the project works great. I did the same procedures on our staging server, but it failed with an impossible error: Server Error in...
0
by: ahusain | last post by:
I'm trying to use impersonation with my asp.net application but once I added the <identity impersonate="true"/> line, my application would give me: Exception Details:...
4
by: Alex Maghen | last post by:
This is weird On my WinXP development box, database calls made from within my GLOBAL.ASAX go to SQLServer as user "ASPNET" even though I have impersonation turned on in my web.config. That's fine...
4
by: Liz Patton | last post by:
Here's the exception: System.Exception: Unable to send mail: Could not access 'CDO.Message' object. ---> System.Web.HttpException: Could not access 'CDO.Message' object. --->...
5
by: hellrazor | last post by:
HI there, I am developing a client side app which requires me to launch another program when a user clicks a button on a web page. I thought I'd create an asp.net page (using c# ) to accomplish...
9
by: Patrick | last post by:
I have an ASP.NET page that searches for someone in the corporate Active Directory. It had been working fine until recently when I changed from Basic Authentication on IIS6 back to Integrated...
7
by: Peter Ritchie | last post by:
I'm writing a Web Service and I would like to add performance counter data for monitoring performance of the Web Service's operations over time and load. The problem is, I get the "Requested...
23
by: deathtospam | last post by:
A day or two ago, I wrote a quick ASPX page with a CS codebehind using Visual Studio .NET 2005 -- it worked, I saved it and closed the project. Today, I came back to the project, reopened the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.