473,790 Members | 2,380 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 18 '05 #1
5 2083
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 18 '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 18 '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 18 '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 18 '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 18 '05 #6

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

Similar topics

5
7432
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...
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...
2
3051
by: Jim Moon | last post by:
Hello. We have SQL Server Stored Procedures that use the "CURRENT_USER" variable. We have SQL Server database fields that call "user_name()" as a default. That has been fine in the use and storage of user names, in the context of being called from IIS 5 and 6, from ASP 3.0 using ADODB. I'll add that the web applications are using Basic Authentication. So, individual user account names are garnered and stored. That is valuable to us.
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 ---
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
9512
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
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...
1
10145
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,...
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
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
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
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

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.