Enable Forms authentication on Virtual directory in IIS 6.0 - asp.net

I have an ASP.NET application in IIS 6.0 with the following structure.
MyApplication is setup to run with Forms Authentication. I have a virtual directory called MyFiles that points to a shared network location containing some pdfs and docs.
The issue is that I am not able to secure this virtual directory with Forms Authentication. If I enable Anonymous access to the virtual directory, users are able to access all documents without login to the site. If I disable Anon access, they cannot access even after login.
I tried setting up MyFolder as an application and keeping a web.config with location tag for the MyFiles virtual directory and denying anonymous. This did not work.
Any help on this would be greatly appreciated.

Related

Protecting a file with Basic Authentication

How do I secure one aspx page with basic authentication, in a website running IIS 8 (Windows Server 2012)? The Forms authentication is used elsewhere on the website, but I need a temporary protection to this particular file with Basic Authentication.
In IIS, I have disabled anonymous authentication on the folder where the file resides, and enabled the Basic Authentication. I have also created the new local user, and given it permissions to read the folder. I would like to use this username/password to access the resource.
Yet, I can access the file without seeing any user name/password prompts.
Try the steps below:
On the IIS Manager application, access your website and select the directory that you want to protect.
On the right part of the screen, access the option named: Authentication.
Disable the Anonymous authentication on the selected directory.
Enable the basic authentication on the selected directory.
In this example, i configured the IIS server to use the basic type of authentication and configured the IIS server to require authentication to access a directory. As an administrator, create a local user account.
net user /add xxxx
To test the installation, open the browser and try to access the protected directory. Enter the URL in the Browser, the IIS server will require you to perform the user authentication.

IIS: System.UnauthorizedAccessException: Access to the path

I have a website and it sits on the IIS Server and I have a folder on another server the file server. I have set the Virtual directory to the folder on the fileserver. This application both servers are on the same domain, but in the future I will have serves that are not on the same domain.
I have tried to set up local users on both machines and set up the app pool to use the local accounts and I get
System.UnauthorizedAccessException: Access to the path is denied.
and
401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied.
I have set the virtual to connect as the local user and get the same error.
I have setup a domain user and then set the app pool to use the domain user and set to use pass through and when I test the settings in Directory Browsing it says everything is good but I get the same error from the webpage.
I have setup a domain user and then set the app pool to use the domain user and set to the connect as to the user and when I test the settings in Directory Browsing it says everything is good but I get the same error from the webpage.
I have set the apppool to use my login and it works with pass through permissions.
Is there something I am missing.
You need to set the folder permissions in your separate folder to give access to the "computer$" account of the server where your application is hosted.
See here: https://www.iis.net/learn/manage/configuring-security/application-pool-identities
application pool identities also use the machine account to access
network resources.
So in the server where you have your data files you should set the folder permissions to allow access to the machine name where your website is hosted.
I had this same challenge when deploying a web app using IIS on a Windows 2012 Server.
The issue was the App Pool Account did not have Full rights to the Website Root.
All I had to do was to go to the directory where the Website Root resides and then right-clicked on it. Next, I selected Security and then gave the IIS-Users group full access to the directory.
For me IIS-Users group contains all Users/App Pool Accounts that are created in IIS.
That's all.
I hope this helps
I have created a domain user specifically for the the virtual directory and it appears to work, but is this best practice?

Where is Anonymous Authentication setting stored in IIS? No web.config created

I added an ASP.NET application under a virtual directory in Default Web Site. When I change the Authentication settings for a subfolder in the application (such as by disabling Anonymous Authentication) I can't find where the setting is being stored. There is no web.config being created in the subfolder, the application's root web.config is untouched and Process Monitor doesn't record any file writes either.
IIS Manager stores Authentication settings in "C:\Windows\System32\inetsrv\config\applicationHost.config" for any website or subfolder. The corresponding section needs to be copied out and into your local web.config.
I just did the same and linked the virtual directory to my smtp Pickup-Directory. Same result.
But: After I restarted the default Website und changed the settings, there was a web config in my smtp-pickup-directory.

Accessing web directory IIS from asp.net webapp IIS 7

So, I've been trying to give my web application read access to files in root/documents folder that I have created. I don't want the public to have access to this folder. Have managed to lock out public users through the documents folder authentication setting by disabling the anonymous authentication setting.
Having much larger problems giving the web app read access to files in that folder. Have added the apppool into the read folder permisions of the documents folder but still getting access denied messages.
Just wondering if there's anything else that may be affecting the applications access to the directory.
Try adding NETWORKSERVICE as a reader to the folder.
On the other hand, you can try using impersonation and give read access to impoersonated user.

IIS7 Creating Virtual Directory to files on another server

I am migrating some ASP.Net applications from IIS6 to IIS7 and all has gone well until now. I am trying to create several virtual directories on 1 server that will point to files on another server. In IIS6, all I had to do was make anonymous authentication use a user that had access to the files. In IIS7, I can't get it to work. I setup the virtual directory with the username and password but I get a 500.19 error "Cannot read configuration file due to insufficient permissions". I can't imagine that I really have to put a web.config in a directory that just contains images and no application files. If I click on the directory in IIS Manager, I get that error about the web.config file on anything that I click on such as the Authentication section. Also, writing to files from the virtual directory seems to work just fine so I don't think there is anyway that I have an access problem. I have given the directory access to the IIS_IUSR group.
When using a virtual directory that's pointed to a UNC share, go to advanced settings for the virtual directory, then choose a specific user account that has the appropriate rights to access the folder.
It works for my virtual directory in my asp.net app that is pointed to a UNC share on a remote server.

Resources