views:

56

answers:

2

I have a web application that creates directories. The application works fine when creating a directory on the web server, however, it does not work when it tries to create a directory on our remote fileserver.

The fileserver and the webserver are in the same domain. I have created a local user in our domain, "DOMAIN\aspnet". The local user is on both servers.

I am running my .Net app pool under the domain user. I have also tried using windows impersonate in the web.config to run under the domain user.

I have verified that the domain user has full control to the remote directory. In an effort to debug this I have also given the "everyone" full control to the remote directory.

In an effort to debug this I have also added the domain user to the administrators group.

I have a simple .net test page on the web server to test this. Through the test page I am able to read the directory on the file server and get a list of everything in it.

I am not able to upload files or to create directories on the file server.

Here's code that works:

var path = @"\\fileserver\images\";
 var di = new DirectoryInfo(path);
            foreach (var d in di.GetDirectories())
            {
                Response.Write(d.Name);
            }

Here's code that doesn't work:

 path = Path.Combine(path, "NewDirectory");
 Directory.CreateDirectory(path);

Here's the error I'm getting: Access to the path '\fileserver\images\NewDirectory' is denied.

I'm pretty stuck on this. Any ideas?

A: 

Check the trust level of the server/site. If you're running at less than Full Trust then you may need to modify your FileIOPermission setting:

<IPermission 
   class="FileIOPermission" 
   version="1" 
   Read="$AppDir$" 
   Write="$AppDir$" 
   Append="$AppDir$" 
   PathDiscovery="$AppDir$"/>

The $AppDir$ macro value expands to the folder your website resides in. You can append additional paths by separating them with semi-colons.

The file you need to edit will be pointed at by the <trust level=.../> setting in the master web.config file in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG, presuming that you're running .NET 2.0.

Kev
A: 

The issue ended up being a path issue.

\fileserver\images\ was mapped to h:\files\http\images

The service had permissions to the drive at H, but not the share.

tmfkmoney