Access to Shared/Mapped Folder with FSO in ASP.net

Posted on 2004-08-31
Medium Priority
Last Modified: 2013-11-25
This issue is starting p*ss me off a bit.

I created a page in regular ASP/IIS 5.0 on my PDC to go find files on my file server and write the links back to the page as HTTP links using a Virtual Directory Path.
So users can click and download the files.

All works fine. I do remember adding a IUSR_IISSERVERNAME account to the File Server to allow me access to the shared files.
Or atleast thats what i thought it was for.

Now I am in the process of doing the exact same thing on a Different IIS server in ASP.net to speed up performance.

I get the error: Logon failure: unknown user name or bad password.
Regardless of how i reference the path. \\Server\Share or H:\Share (Mapped Drive) i get this error. I even tried \\server\H$\Share
I tried adding the new IUSR_IISSERVERNAME to the File Server and gave the account read permissions but with no success.

i call the file lookup with the System.IO.Directory.GetFiles(path,name) command
I am sure this a permissions issue relating to the IUSR_SERVERNAME account not having the rights to access the network share.

Any help would be greatly appreciated with this.

To make things more clear here is a link with basically my exact same problem

Question by:DTRON04
  • 3
  • 3
  • 2
LVL 17

Assisted Solution

AerosSaga earned 400 total points
ID: 11945096
did you try both of these workarounds?

This was well documented for ASP,
and should behave the same way for ASP.NET,
since it's a permissions problem.

Basically, when you access a dir/file on a network share,
it's your MACHINE which is accessing and the user
account doing the accessing is IUSR_computername.

Resolution is creating a user account on the computer on which
the network share resides and assigning the proper access
permissions to that account. This account MUST be named
with the EXACT name AND password which the anonymous
account has in the box hosting the web server ( and ASP.NET ).

Some database operations run under the SYSTEM account.
Those operations will fail with database files on the network share.

But directory listings and other operations on text/xml/html files,
like parse/copy/modify/delete, will work.


Juan T. Llibre
Microsoft MVP [IIS/ASP]
ASP.Net En Español :


If you are usoing winNT you will notice the difference when you assign a directory tu a website in IIS

Local drives are assigned differently than the network drive (2 different choices) That means the IIS treat them differently. Can you get a clue from this.

I think if the directory is a sub directory of the web dir assigned in IIS it will work. Others have to be accessed via a virtual dir.

Create a virtual dir in IIS for the net work drive you want to acces and then access the virtual dir from ASP.net.

This should work.

I am sure there is a similar procedure in Appache also!

Author Comment

ID: 11945360
hey aero

well i tried the IUSR_IISSERVER2 added to the local Filer Server account but it does not treat it the same way it treats my PDC IUSR_ACCOUNT.
Basically active directory does not list the IUSR account for the second web server. So i think that is why it is not working.

With the virtual directory solution what would be the specific path i should use?
That is what is confusing me.

I know how to buld the http link to use the virtual directory but is this how i should reference when doing the FSO lookup.

LVL 17

Expert Comment

ID: 11945457
I think what its saying is that once you tell create a virtual directory in IIS you can reference it from the virtual root of the IIS dir like /MyMapedServerVirtualDirectory/files.aspx
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

LVL 10

Expert Comment

ID: 11945576

You probably need to add the following to your web.config:

<identity impersonate="true" />

This is not in web.config by default, and this causes ASP.NET to attempt to access server resources under the local ASPNET account.  With allow anonymous enabled, when you add the identity tag above, it will tell ASP.NET to use the IUSR_<machine> account instead.  This should solve the problem.


Author Comment

ID: 11945929
Okay i added that line to web.config
Now instead of the error it prompts me for user name and pass when it tries to access the share.
or when typing in the exact path to a file in the virtual directory as the address.

Here is what i have done so far.

Setup Virtual Directory with anymouse access and connected with the administrators account
Added the IUSR_IISSERVER user to the FS01 to match what the actual IIS default account.
Added the <identity impersonate="true" /> to the web.config

Now i did find this article that addresses my issue with a COM+ solution.

Have either of you guys done what i am trying to do?
If so did it work for you?

LVL 10

Accepted Solution

jnhorst earned 1600 total points
ID: 11948868
OK, I think I see.  I originally thought you were trying to get to files on your PDC box (the one with IIS, right?).  Since you are trying to navigate to another server by way of a UNC path (I assume), what you want to do is create a *domain* account (not a local account on the file server) and give that domain account the necessary privileges for the file share.  Then change the IIS setting to use that domain account to authenticate anonymous requests.  Leave the <identity /> tag in web.config.

I did something like this before where I built a menu system based on the folder tree of a share on the file server and then had links to the files that were in the folders.  I had to have a domain account for anonymous access so I could grant persmission to the file server share.



Author Comment

ID: 11951201
Well i am fresh this morning
Thanks jnhorst your explanation worked perfectly.
im not sure why i couldn't contemplate that yesterday but all looks perfect now.
I appreciate both your answers as they were correct.
Aeros you will be getting the full 500 from the other question you helped me with yesterday.


LVL 17

Expert Comment

ID: 11951307
Your very welcome, glad I could be of some assistance.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question