How? Granting elevated privileges to a web service / kill a process

L

Lee Gillie

I need to be able to kill a process programmatically under ASP.NET. IIS
runs under the local system account. The user accessing the web is using
anonymous access.

We would prefer NOT to grant elevated security to the proxy used for
anonymous access. Is there a way to either establish a temporary
security context, programmatically for the .NET Framework Process.Kill
to operate under? Or perhaps a way to give the compiled binary produced
this privilege? We may be willing to hard code a username credential in
code in order to help limit the broad scope assignment of privileges.

The need for this comes from what I believe to be a bug in EXCEL. We use
automation in ASP.NET code. We wind everything down, call the various
closes, and release all references, but we find the web server to be
soon littered with many orphaned EXCEL processes. One for each instance
made via automation.

We have developed an approach to see the new EXCEL process being created
at the very moment we instance EXCEL, and track the PID. When we have
done absolutely everything we can to release the workbook, and close
EXCEL, and it still has not gone away, then we kill the process. This
has worked in many contexts, but falls on its face in an ASP.NET
webservice due to the fact that it has insufficient privileges.

Thanks for your help. Best regards - Lee Gillie, Spokane WA
 
K

Ken Cox [Microsoft MVP]

He Lee,

It seems to me that you'd want to create a special password-protected page
and implement impersonation for that page. The impersonation would use the
ID/password of an account that has sufficient privileges (admin?) to execute
Process.Kill.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsent7/html/vxconimpersonation.asp

The account will have to have broad permissions:

"SecurityPermission for calling any members of System.Diagnostic.Process
with full trust. Associated enumeration: PermissionState.Unrestricted "
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top