Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET - How do you find the process identity?

Tags:

asp.net

How do you determine the process identity for ASP.NET? I am getting an UnAthorizedAccessExeption when a user clicks a LinkButton designed to use System.IO to delete a file located in a subfolder of the root folder for a Web Application Project in Visual Studio 2008.

like image 428
dannyrosalex Avatar asked May 18 '10 12:05

dannyrosalex


2 Answers

For the user running the process: Environment.UserName

For the person requesting the page: Page.User.Identity

Edit: Network Service is the default account used for serving content across the network (e.g. IIS). See all built-in accounts. You'll have to give Network Service access to the folder (giving all your other websites that use this account access as well) or set up another account.

Are you using IIS 6 or 7?

like image 128
Nelson Rothermel Avatar answered Oct 31 '22 08:10

Nelson Rothermel


I'm assuming you want to obtain the process identity within the execution of the ASPX page. In that case:

System.Security.Principal.WindowsIdentity.GetCurrent().Name;
like image 31
Cheeso Avatar answered Oct 31 '22 07:10

Cheeso