473,790 Members | 2,481 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with aspnet "impersonat ion"

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="tr ue" />

and the code in the asp.net page:

private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
System.Security .Principal.Wind owsImpersonatio nContext
impersonationCo ntext;

impersonationCo ntext =
((System.Securi ty.Principal.Wi ndowsIdentity)U ser.Identity).I mpersonate();

System.Diagnost ics.Process.Sta rt("notepad.exe ")

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

Jorge
Nov 16 '05 #1
5 7432
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***@anothe r-world.com> wrote in message
news:Xn******** *************** ***********@207 .46.248.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="tr ue" />

and the code in the asp.net page:

private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
System.Security .Principal.Wind owsImpersonatio nContext
impersonationCo ntext;

impersonationCo ntext =
((System.Securi ty.Principal.Wi ndowsIdentity)U ser.Identity).I mpersonate();

System.Diagnost ics.Process.Sta rt("notepad.exe ")

impersonationCo ntext.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***@anothe r-world.com> wrote in message
news:Xn******** *************** ***********@207 .46.248.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="tr ue" />

and the code in the asp.net page:

private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
System.Security .Principal.Wind owsImpersonatio nContext
impersonationCo ntext;

impersonationCo ntext =
((System.Securi ty.Principal.Wi ndowsIdentity)U ser.Identity).I mpersonate();

System.Diagnost ics.Process.Sta rt("notepad.exe ")

impersonationCo ntext.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.Diagnost ics.Process.Sta rt 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 CreateProcessAs User as support for this is
not in .net.
3) System.Diagnost ics.Process.Sta rt("notepad.exe ") - notepad will fail
because it will try to open a window, not notmally allowed from a service.

-- bruce (sqlwork.com)

"hellrazor" <jo***@anothe r-world.com> wrote in message
news:Xn******** *************** ***********@207 .46.248.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="tr ue" />
|
| and the code in the asp.net page:
|
| private void Page_Load(objec t sender, System.EventArg s e)
| {
| // Put user code to initialize the page here
| System.Security .Principal.Wind owsImpersonatio nContext
| impersonationCo ntext;
|
| impersonationCo ntext =
| ((System.Securi ty.Principal.Wi ndowsIdentity)U ser.Identity).I mpersonate();
|
| System.Diagnost ics.Process.Sta rt("notepad.exe ")
|
| impersonationCo ntext.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******** ******@TK2MSFTN GP12.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.Diagnost ics.Process.Sta rt 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 CreateProcessAs User as
support for this is not in .net.
3) System.Diagnost ics.Process.Sta rt("notepad.exe ") - notepad will fail
because it will try to open a window, not notmally allowed from a
service.

-- bruce (sqlwork.com)

"hellrazor" <jo***@anothe r-world.com> wrote in message
news:Xn******** *************** ***********@207 .46.248.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="tr ue" />
|
| and the code in the asp.net page:
|
| private void Page_Load(objec t sender, System.EventArg s e)
| {
| // Put user code to initialize the page here
| System.Security .Principal.Wind owsImpersonatio nContext
| impersonationCo ntext;
|
| impersonationCo ntext =
| ((System.Securi ty.Principal.Wi ndowsIdentity)U ser.Identity).I mpersonate
| ();
|
| System.Diagnost ics.Process.Sta rt("notepad.exe ")
|
| impersonationCo ntext.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***@anothe r-world.com> wrote in message
news:Xn******** *************** ***********@207 .46.248.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="tr ue" />

and the code in the asp.net page:

private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
System.Security .Principal.Wind owsImpersonatio nContext
impersonationCo ntext;

impersonationCo ntext =
((System.Securi ty.Principal.Wi ndowsIdentity)U ser.Identity).I mpersonate();

System.Diagnost ics.Process.Sta rt("notepad.exe ")

impersonationCo ntext.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
1591
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 Trusted connection or get a file information using FileInfo class). This is probably because my application is running under PETER\ASPNET account, where PETER is my computer's name. I can solve this problem by using Impersonation. However, when...
1
6135
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 '/' Application. -------------------------------------------------------------------------------- Access denied to 'C:\Inetpub\wwwroot\myapp\default.aspx'. Failed to start monitoring file changes. Description: An unhandled exception occurred...
0
1371
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: System.ApplicationException: Access is denied. If I add my username/password to the identity tag (my account is under the Administrator and Debugger Users groups) I get the following: Could not create Windows user token from the credentials specified in
4
2030
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 Now, when I move the whole application over to my Windows 2003 Server box, during the GLOBAL.ASAX calls to SQLServer, I get "Login failed for NT AUTHORITY\NETWORK SERVICE." I don't understand this. "NT AUTHORITY\NETWORK SERVICE" isn't even a user...
4
3977
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. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80004005): Unspecified error --- End of inner exception stack trace ---
5
2083
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 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...
9
3180
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 Windows authentication. The error occurs on the FindAll method. The exceptions are as follows. anyway of getting the code working with Integrated Windows authentication (too annoying for user to enter user-name/password). Note I do need to use...
7
12107
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 registry access is not allowed." SecurityException when I try and create the performance counter category via PerformanceCounterCategory.Create(). I understand the login used to run the Web Service does not have access to the registry keys...
23
5141
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 solution, and was greeted with the following error: ======================================================================== It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error...
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10413
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9986
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.