Creating a virtual directory to a non-local (remote) folder in IIS 6 - iis

I have a shared folder on a server that contains some files I want to be able to serve through IIS on a separate server.
I created a virtual directory pointing to the the shared folder in IIS, and have it use windows authentication.
The shared folder has "Everyone" set to have read permissions. When I try to open a file through localhost on the iis server, everything loads correctly, however when I substitute localhost with the actual name of my iis server it brings up an error
You do not have permission to view this directory or page due to the access
control list (ACL) that is configured for this resource on the Web server.
I opened up process monitor and saw I was getting Access Denied when the Network Service account (the account my app pool is set to run as) was being denied read permissions to the virtual directory. I implicitly added network service to the security permissions with read and write permissions and I still get the same error.
Any ideas what I could be doing wrong?

Related

Best way to access the shared folder for a web application

I have two machines, Machine A and Machine B in LAN connection. I have shared a folder on Machine A called "SharedFiles" by giving access to "IUSR" and "IIS USER "  and local user.
I have hosted a web application with IIS on machine B. From this hosted application , I want to access the "SharedFiles" folder.
What is the best way to access the shared folder for the web application ? I found below two options.
 1. By changing the Web application's pool identity. Set a custom account for this pool identity where credentials should be the same as the shared folder or vice versa.
 2. By setting up a virtual directory for this. I don't know how to use it. I have read the theory but never use it before.
If option 2 is correct then , do we need to access that folder using http/https?  How does this virtual directory work(Not looking for steps but logical flow)?
To add the virtual directory with the shred path under your site you could follow the below steps:
1)Open iis manager.
2)Right-click on your site ->slect add a virtual directory.
3)in add virtual directory box enter any name and your share folder path
Note: Make sure you have assigned the iis_iusrs and iusr permission to the shared folder.
After doing this go back again select site.
Double click authentication.
Select "Anonymous authentication"
Click edit from the action pane.
application pool identity. click ok.
now you can access your shared folder in browser with your site bindings/virtual directory name like shown below:
you could use the iis application pool identity to the administrator or local system account.

File Table (SQL Server 2016) FILESTREAM permissions lost in IIS

I am trying to store images in a FileTable that is accessible from a website.
According to my understanding, the FileTable needs "SELECT" granted to the account running ApplicationPool that the website runs in.
Example of what I have:
IIS (6.2)
Application pool user : Domain\Bob.
SQL Server login Domain\Bob
Database has Domain\Bob in db_owner group. I explicitly granted Domain\Bob select on the file table also.
DB.dbo.FileStream_FileTable is \\DEV\FileStream_FileTable\
IIS has SiteA
SiteA has virtual directory Image targeting \\127.0.0.1\DEV\FileStream_FileTable\
If I look at the IIS authentication, IIS errors saying insufficient permission to access web.config - but there is no web.config.
On the server, running Internet Explorer, referencing an image as \\127.0.0.1\DEV\FileStream_FileTable\<...>\Image1.jpg it resolves to the jpg.
On the server, running Internet Explorer, referencing an image as HTTP://127.0.0.1/SiteA/Image/Image1.jpg, IE errors (same error as the authentication error)...
Config Error
Cannot read configuration file due to insufficient permissions
Config File
\?\UNC\127.0.0.1\dev\ItemImage\web.config
There IS no config file.
I have tried specifying the Windows user (Domain\Bob) context when accessing the virtual folder "Images" targetting \127.0.0.1\DEV\Filestream_FileTable
and also not specifying the windows credential...
I do not understand why the Image is visible using the UNC path in Internet Explorer (it must authenticate my context as having select on the filestream_filetable table) but not when using the context specifying a Windows context of a user who also has select on the table, in IIS.
NOTE: As an experiment, I modified the user, in IIS, used to access the share to Administrator. Then the IIS site resolved the image.
(Virtual directory targetting the \\servername\sql_instance_filestream_handle\directory\tablename)
The Windows User Domain\Bob has full rights on database - database owner.
There is another user's question, Access to SQL Server FileTable from IIS, that has servername in file share being a potential issue if the IIS and SQL server is on the same host, which I have taken into consideration.
I have added Domain\Bob to IIS_ISURS group...
What is Domain\Bob not a member of that grants access?
I can't very well make all my IIS shares accessing with Administrator accounts!
In some case, IIS will try to create web.config if the UNC path just return access denied error. If IIS failed to create web.config, It will also fail to access web.config with 500.19.
So please ensure your Application pool identity is set to a domain account who have read/write permission to access the folder.
Then please try to set Anonymous authentication->edit..->Application pool identity.
The Windows user Domain\Bob was not a login in the DEV sql instance.
Creating a sql login solved it. blush
Database level had the user, yes, but the SQL server didn't have a login.
facepalm

Accessing a file on the server from my asp.net web application

In my asp.net web application I am trying to retrieve images from a shared network folder. When I put this website live in IIS, I am getting an error that "Access to the path is denied" when I try to access the network folder. What is considered the user that IIS uses, and how would I grant permissions to the network folder?
Thank you.
The issue is because your application pool identity or the user that IIS is using to run the worker process does not have permissions on the network path.
You may want to grant this user permission on the network path. However, if you are using IIS AppPoolIdentity that is not possible as they are built-in account per machine. As is the same with any buit-in account.
I would advice you to use a network account and give that account appropriate permissions on both IIS and the network share.
You may have to add this user to the IUSR group.

Local site within Dropbox using IIS

I am trying to have my local website within dropbox using IIS. When I add the dropbox directory I get the error: The server is configured to use pass-through authentication with a built-in account to access the specified physical path. However, IIS Manager cannot verify whether the built-in account has access. Make sure that the application pool identity has Read access to the physical path. If this server is joined to a domain, and the application pool identity is NetworkService or LocalSystem, verify that \$ has Read access to the physical path.
I am admin and have allowed all access to the dropbox folder. What is wrong?
You should add IIS user account to the list of users who are allowed to view/read the files. IIS usually runs via separate user account for security reasons.
This is done the following way:
Right-click on your site folder in Dropbox
Select "Security"
Click "Add"
Find IUSR user and/or IIS_IUSRS group
Add them both (or one, if only one is present) and assign them read permissions
Try adding your site folder again.
This should fix the issue.

IIS Virtual Directory map to network drive (with drive letter) but fail to create file

I am using C#/ASP.NET, IIS6 on Windows Server 2003.
Map the data server shared folder to the WebServer with driver letter V:\
On the WebServer, IIS created a virtual directory and pointed to 'local location' with V:\ . Since there is no 'Connect As', not sure which USER will be used
In my WebMethod, I want to create file on the shared folder with FileStream.Write().
I got IO Exception on the action, any hint?
P.S. I have added ASPNET/NETWORK SERVICE on the data server shared folder.
thanks!
Gavin
Mapped network drives are specific to the user account that created them:
Using Mapped Drives with IIS - MS KB257174
The preferred method of accessing content for the Web server that exists on a remote computer is to use shares that follow the universal naming convention (UNC).
It's very likely that NETWORK SERVICE (or if you're running ASP.NET under impersonation, the site anonymous account) hasn't got this mapping.
To change the location where the virtual directory points to, browse to your site in IIS manager, right click on the virtual directory and select properties. You can then select "A share located on another computer":
The website in IIS has a corresponding app pool and this should tell you the user under which your code wil be running.
You'll the have to grant the appropriate permissions for that share for that user.

Resources