ASP.NET Accessing shares

G

Guest

Hi,

I'm working on an ASP.NET application that allows users to upload images to
a central storage area and view using a HTTP handler.

This works great if the files are stored on a local drive on the web server.
The problem I have is that when I move this storage area to a share on
another machine with full permissions for everyone I still get
System.IO.FileNotFoundException.

Are there any other additional other permissions for the ASPNET account on
the web server that need to be set before I can access remote shares?

Many thanks
 
G

Guest

Serge,

The machines are not part of a domain so the ASPNET account is only on the
web server and therefore I cannot give permissions to the user directly on
the share.

Going to read article posted by flipdoubt.

Thanks
 
J

JIMCO Software

Oliver said:
Hi,

I'm working on an ASP.NET application that allows users to upload
images to a central storage area and view using a HTTP handler.

This works great if the files are stored on a local drive on the web
server. The problem I have is that when I move this storage area to a
share on another machine with full permissions for everyone I still
get System.IO.FileNotFoundException.

Are there any other additional other permissions for the ASPNET
account on the web server that need to be set before I can access
remote shares?

In a scenario like this, you should use P/Invoke to do code-level
impersonation. You can then impersonate a user (or group) who has access to
that share.

http://support.microsoft.com/default.aspx?scid=KB;EN-US;306158

See "Impersonate a specific user in code".

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003
 
K

Kevin Spencer

First, the FileNotFoundException doesn't indicate a problem with
permissions. It means that the file cannot be found. In other words, your
path is wrong.

The best way to access a network share is to use a UNC path (e.g.
\\192.168.1.1\c$\somefolder\somefile.txt).

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
J

JIMCO Software

Kevin said:
First, the FileNotFoundException doesn't indicate a problem with
permissions. It means that the file cannot be found. In other words,
your path is wrong.

It is possible to see a FileNotFoundException when you are experiencing
permissions problems.

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003
 
G

Guest

I agree, I can open the file by pasting the UNC into explorer no problem -
just not through ASP.NET
 
G

Guest

Jim,

I was really trying to avoid having modify the application to impersonate a
user (not lazy just time constraints). So I just opened the share for full
access by everyone but no luck. At this rate it will quicker to re-write the
code.
 
J

JIMCO Software

Oliver said:
Jim,

I was really trying to avoid having modify the application to
impersonate a user (not lazy just time constraints). So I just opened
the share for full access by everyone but no luck. At this rate it
will quicker to re-write the code.

If you are not impersonating, that means that the worker process account is
being used to access the share. It's possible that it's failing because of
that. I would set a password for the process account and then configure an
identical account on the file server. This will allow for pass-through
authentication.

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003
 
K

Kevin Spencer

I was not aware of that. I suppose that the permissions exception might be
found in the InnerException. At any rate, I stand corrected!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
K

Kevin Spencer

Hi Oliver,

Apparently I was mistaken. If it is indeed a permissions issue, your ASP.Net
app may be running under a local machine account, rather then a
domain-accessible account. The following MSDN article will provide you with
the information you need to access a network share via the ASP.Net user
account:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/THCMCh19.asp

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top