What Windows account does an ASP.NET 4 application run under? - asp.net

What Windows user account does an ASP.NET MVC 4 app run under?
When I deploy my MVC app to IIS 7, it isn't writing exceptions to the log file. I stepped into the source while the application was deployed and found that it didn't have rights/the required privileges to write to the log file.
So, I want to grant more privileges to the account that the app is running under.

Go to:
IIS > Application Pools > (right-click) the Application Pool > Advance Settings... > (Under Process Model) Identity.
You can change it if you want. It should be ApplicationPoolIdentity.

That's just depend on what's the path you're going to write. For example, if you're deploying your asp.net website use default "Network Service" account, you should grant the right permission to it.
To get the account you're currently using, you can check the identity of the app pool for your website.

Using IIS 8.5?
The ApplicationPoolIdentity is a member of the IIS_IUSRS group. If you need to give the app direct access to the file system set the ACLs for IIS_IUSRS.
However, exposing the file system to the web required very careful consideration.

Related

Access to file write.lock in ASP.NET web application writing a Lucene search index

I created an ASP.NET application that uses Lucene for searching my web pages. Locally, everything works fine, but when I deploy it to the IIS server, the code that generates the write.lock file during the creation of the index, gives the following error:
Access to the path 'C:\inetpub\wwwroot\GcsWeb\OnlineHelp\write.lock' is denied.
I'm sure this has to do with the fact that the account under which the web app is running, does not have permission to write files to the web application folder.
How can I fix this? The file itself is not being created so I cannot right-click it and set the security permissions. It has to do with the fact that, maybe, it needs permission to write files, correct? If yes, then how do I do this? Not familiar with IIS security. Using IIS version 8.5 on Windows Server 2012 R2.
You need to find out from the application pool for the website what is the identity it is running under (by default this is Application Pool Identity) and grant that the correct permissions.
You can try this setting:
IIS > Application Pools > [your site] > Advanced Settings > Identity >
Built-in accound > LocalSystem
Check the user identity running the IIS app (usually NETWORK SERVICE) and ensure that user has the proper rights to the applicable folders.

Accessing Local Service

Hope you can help.
We have a web application (.NET 2.0) that has some custom code that is used to poke a windows service when a file is uploaded. We issue a command using the following code:
Dim serviceName As String = "Processor Service 1.0"
sc = New ServiceController(serviceName)
sc.ExecuteCommand(200)
Running this code in a standalone app works fine but when running through website throws an access denied error. Code works fine in IIS 6.
We are using an application pool with a user and is in Admin group. I figure it's something to do with IIS but now sure what.
Hoping you guys can help.
Thanks
The permissions that are needed to interact with local services are pretty high. Your asp.net app is likely running as anonymous (local account IUSR), or the "application pool identity". You would have setup your app in IIS (app pool) to use a different account with greater permissions.
In IIS Admin, under the section "IIS", "Authentication", you need to enable a stronger authentication method. If "Anonymous Authentication" is the only one enabled, then check the settings "Edit" to see if it is running as IUSR or "Application pool identity". This is where you determine, or set, the account (and permission set) that your ASP.NET app is using.
I feel that I should strongly warn against elevating the permissions for IIS and anonymous users. This would create a very dangerous back-door into your system. The suggestion from bgs264 is a very good one: make a separate service (or scheduled process) that watches for file uploads, or modify the existing service to use the file-watcher to monitor for uploaded files. It could run under a higher permission set and would be much more isolated from your IIS. Granting admin permissions to IIS or its app pools, is just like begging for trouble.

How to find application user name (ASP.NET/IIS)

I'm trying to track down why when the web app accesses a network drive, I see Network path not found (error 53). When I log into the server I can open up a file on that drive with no problem. But the application (asp.net) cannot. I was wondering if this was a permissions error and that lead me to try to find out what the usename of the app is and where I would find that out.
It depends on your OS version and your security settings. Your web-site should have an app pool assigned to it (which may be shared with other applications). By default in windows server 2008R2 the pseudo account ApplicationPoolIdentity is used, which is not really an account.
IIS Accounts
You can check under advanced settings for the app pool and see what it is using. I believe if you have impersonation set up in your web.config, the app pool will access resources using the credentials of whomever is using the application--you can use Kieran's snippet to get that information.

ASP.NET error log

Every time the ASP.NET application in question throws an error the Global.asax writes to an error file: logs\error.log. The ASP.NET applications works using Windows authentication.
I am able to write to the log file when debugging using Visual Studio, however it does not work when the application is deployed in the live environment. How do I find out what user account I need to give access to: logs/error.log?
The application is deployed on a Windows 2003 Server with IIS6. Microsoft.NET 3.5.
You would have to give the required permissions to the network service account. This link might be able to help you out.
Windows Server 2003 defaults to the "Network Service" account.
This can be verified by opening IIS (expand the computer if needed), expand the "Application Pools" folder, right click on the pool used by your web app, and go to the Identity tab.
FYI: Windows Server 2008 uses the IIS_IUSER instead of Network Services.
I hope that logs folder is a virtual directory setup outside the web site directory.
Otherwise every time you deploy the entire solution you will overwrite the logs folder and its content.
Microsoft has a tool for monitoring file access that can be useful for troubleshooting permission issues.
Process Monitor - http://technet.microsoft.com/en-us/sysinternals/bb896645
You will also want to check if your application is using windows authentication & identity impersonation since that can change the identity the application is executing with when enabled.

Deploying a web application on the IIS 5

I am in the process of deploying a web application on IIS5 on my server which runs windows XP.So when i run my application in visual studio its perfect.But when i deployed it into IIS it throws me an error saying that the access denied to a particular file.
My app reads a xml file based on the input(which is nothing but the other system in the network).As i browsed to the properties of that file manually and unchecked the read only attribute,still it dint work out.Can any one guide me to the proper solution ?
you might have to give read/write (if needed) to following users:
iis_wpg
network service
aspnet
In IIS, your site runs under the credentials of the application pool assigned to it. You can either change the credentials of your application pool to an account that has permission to access that file, or else grant access to the default account that the application pool is currently using.
You mention that you are using basic auth...
Generally, the web application will then impersonate the user logged in.
So, if your file isn't accessible by the user that logged in, then it won't be accessible to the web application impersonating them on the system either. You will need to check the permissions of those files and set them accordingly.

Resources