473,779 Members | 1,913 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 7431
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
6130
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
1369
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
2028
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
12106
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
9636
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
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
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...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9930
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
8961
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
7485
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
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.