By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,473 Members | 3,229 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,473 IT Pros & Developers. It's quick & easy.

File access problems

P: n/a
Hi,

I have what seems to be a common problem, but the solutions I've found don't
seem to work. I would like to use a web service to create a file at a UNC
location in a shared file. Currently I'm just running it locally and saving
the file locally using my machines UNC path.

I have given user ASPNET full control over the folder I want to write the
file to. I've also tried using the web config identity impersonation to use
my user with full access to the folder.
In each case I error out with the
:System.UnauthorizedAccessException: Access to the path <UNC path> is denied.

The error occurs when I hit this line.
Dim fw As New
StreamWriter(System.Configuration.ConfigurationSet tings.AppSettings("FilePath"), False)

The FilePath is just \\machinename\sharedfolder\file

thank you,

--
Duffman

can't get enough of that wonderful Duff
Nov 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Duffman,

Welcome to MSDN newsgroup.
From your description, you're trying to access and modify a remote UNC
shared folder in your asp.net webservice's webmethod and you're getting
:System.UnauthorizedAccessException: Access to the path <UNC path> is
denied.
which indicate the permission issue, yes?

As for such scenario, there're several things need to pay attention. First
our asp.net webservice's security configuration.
What's your asp.net webservice's hosting server, win2k/iis5 or win2k3 iis6,
they'll have different process model. Anyway, we first need to use a
certain account to running the asp.net webservice so that it is valid to
the remote machine. And since the MACHINE\ASPNET account is a local
account, it's not valid one to remote machines. When using such a account
to access remote resource, the remote server will treat it as a invalid
identity and establish NULL session. So you can use a domain account or a
duplicated mapping local account( which has the same username/password on
both machines) to run your asp.net webservice.

Also, you can check the Eventlog on the the remote UNC share's server which
will provide the error info about the access denied error, you can get
what's the identity used to access the fileshare.

In addition, to allow anonymous user access fileshare, we need to grant
everyone the certain permission. And on W2K3server, there is an additional
privillege named
"Network access: restrict anonymous to Named pipes and shares"

by default it's enabled, you'll need to disable it so as to allow anonyous
access file share.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
Thread-Topic: File access problems
thread-index: AcXJHKxu7A9lpLCARIOaqFPDDQRmQw==
X-WBNR-Posting-Host: 206.230.64.253
From: "=?Utf-8?B?RHVmZm1hbg==?=" <Du*****@newsgroup.nospam>
Subject: File access problems
Date: Tue, 4 Oct 2005 12:49:03 -0700
Lines: 25
Message-ID: <E7**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
microsoft.public.dotnet.framework.webservices:8107
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

Hi,

I have what seems to be a common problem, but the solutions I've found
don't
seem to work. I would like to use a web service to create a file at a UNC
location in a shared file. Currently I'm just running it locally and
saving
the file locally using my machines UNC path.

I have given user ASPNET full control over the folder I want to write the
file to. I've also tried using the web config identity impersonation to
use
my user with full access to the folder.
In each case I error out with the
:System.UnauthorizedAccessException: Access to the path <UNC path> is
denied.

The error occurs when I hit this line.
Dim fw As New
StreamWriter(System.Configuration.ConfigurationSet tings.AppSettings("FilePat
h"), False)

The FilePath is just \\machinename\sharedfolder\file

thank you,

--
Duffman

can't get enough of that wonderful Duff

Nov 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.