473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Access to the path .... is denied

Hi there,

There was older thead i created for that question a week ago, but then
I had some sort of vacations, and couldn't participate.
Basically I am getting Access to the path "Path name" is denied when I
execute the following code on my production server (W2003)

Dim myFolder As String = Server.MapPath("..\..\..\sDirectory\")
Dim FileName As String

For Each FileName In Directory.GetFiles(myFolder , "*.doc")
Response.Write(FileName)
Exit For
Next

This code will run just fine on my testing machine (Windows XP)

sDirectory is a virtual directory.
Anonymous is turned off.
DIgest authentication for Windows domain servers is selected.
Basic authentication is selected.
..Net Password authentication is not selected.
Permissions on the file:
Administrator (Domain\Administrator)
aspnet_wp account (computerName\ASPNET)
Authenticated Users
Everyone
I don't use identity impersonate in my web.config.
I found many discussions regarding that problem, unfortunatelly still
cannot resolve it by myself...

May 10 '06 #1
11 2498
I know this sounds hokey, but have you looked at the populated myFolder
string variable to see what the translated path actually is, and whether it
is valid? You could do a Trace write of this and turn on page tracing
temporarily to see it.

Otherwise, the identity your app runs under (whether the ASPNET account IUSR
or however else it's configured) needs to have the required permissions on
this folder on the target machine.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"j_****@hotmail.com" wrote:
Hi there,

There was older thead i created for that question a week ago, but then
I had some sort of vacations, and couldn't participate.
Basically I am getting Access to the path "Path name" is denied when I
execute the following code on my production server (W2003)

Dim myFolder As String = Server.MapPath("..\..\..\sDirectory\")
Dim FileName As String

For Each FileName In Directory.GetFiles(myFolder , "*.doc")
Response.Write(FileName)
Exit For
Next

This code will run just fine on my testing machine (Windows XP)

sDirectory is a virtual directory.
Anonymous is turned off.
DIgest authentication for Windows domain servers is selected.
Basic authentication is selected.
..Net Password authentication is not selected.
Permissions on the file:
Administrator (Domain\Administrator)
aspnet_wp account (computerName\ASPNET)
Authenticated Users
Everyone
I don't use identity impersonate in my web.config.
I found many discussions regarding that problem, unfortunatelly still
cannot resolve it by myself...

May 10 '06 #2
re:
Dim myFolder As String = Server.MapPath("..\..\..\sDirectory\")
sDirectory is a virtual directory.
Do you have AspEnableParentPaths set to true ?
To increase security, parent paths are disabled by default.

http://msdn.microsoft.com/library/de...1ed541e3a5.asp


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<j_****@hotmail.com> wrote in message news:11********************@g10g2000cwb.googlegrou ps.com... Hi there,

There was older thead i created for that question a week ago, but then
I had some sort of vacations, and couldn't participate.
Basically I am getting Access to the path "Path name" is denied when I
execute the following code on my production server (W2003)

Dim myFolder As String = Server.MapPath("..\..\..\sDirectory\")
Dim FileName As String

For Each FileName In Directory.GetFiles(myFolder , "*.doc")
Response.Write(FileName)
Exit For
Next

This code will run just fine on my testing machine (Windows XP)

sDirectory is a virtual directory.
Anonymous is turned off.
DIgest authentication for Windows domain servers is selected.
Basic authentication is selected.
.Net Password authentication is not selected.
Permissions on the file:
Administrator (Domain\Administrator)
aspnet_wp account (computerName\ASPNET)
Authenticated Users
Everyone
I don't use identity impersonate in my web.config.
I found many discussions regarding that problem, unfortunatelly still
cannot resolve it by myself...

May 10 '06 #3
I actually print myFolder path, then copy and paste to explorer and can
access it...
AspEnableParentPaths was not set to true, I did that but it didn't fix
my problem.
My xp machine has this option disabled and still works...

May 10 '06 #4
I did one more test.
I created another virtual directory, that points to some folder on my
server (local)
Then used same code to access it and it worked.
Then I checked permissions on both folders under security tab, and they
seem to be similar. The only difference is local one has
localMachineName/ASPNET and network has anotherMachineName/ASPNET.

May 10 '06 #5
Please save the following code as "identity.aspx", and run it in the same directory
as the file which is giving you the "access denied..." error message :

identity.aspx
-------------
<%@ Page Language="VB" %>
<%@ Import NameSpace = System.Security.Principal %>
<script runat="server">
Sub Page_Load()
Dim tmp As String = WindowsIdentity.GetCurrent.Name()
Label1.Text = tmp
End Sub
</script>
<html>
<head>
<title>WindowsIdentity.GetCurrent.Name()</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" Runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
----------

When you run the file, make note of the account returned as the asp.net identity.
Then, give read/write/change permissions to *that* account for the "myFolder" directory.

Let us know what happens when you do that.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<j_****@hotmail.com> wrote in message news:11**********************@y43g2000cwc.googlegr oups.com...
I actually print myFolder path, then copy and paste to explorer and can
access it...
AspEnableParentPaths was not set to true, I did that but it didn't fix
my problem.
My xp machine has this option disabled and still works...

May 10 '06 #6
WindowsIdentity.GetCurrent().Name will print NT AUTHORITY\NETWORK
SERVICE
User.Identity.Name will print myDomain/myUserName.

So I added read/write/change permissions to myDomain/myUserName -
didn't help.
Now, I don't have user called NT AUTHORITY\NETWORK SERVICE on my
domain, nor on the box that has the folder. Should I create one? On
domain?

May 10 '06 #7
I beleive that NETWORK SERVICE account is created automatically if you are
on Win 2k3

SA

<j_****@hotmail.com> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
WindowsIdentity.GetCurrent().Name will print NT AUTHORITY\NETWORK
SERVICE
User.Identity.Name will print myDomain/myUserName.

So I added read/write/change permissions to myDomain/myUserName -
didn't help.
Now, I don't have user called NT AUTHORITY\NETWORK SERVICE on my
domain, nor on the box that has the folder. Should I create one? On
domain?

May 10 '06 #8
re:
Now, I don't have user called NT AUTHORITY\NETWORK SERVICE
on my domain, nor on the box that has the folder. Should I create one?
NT AUTHORITY\NETWORK SERVICE is a local account, not a domain account.

Are you running your ASP.NET web server on a domain server ?

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<j_****@hotmail.com> wrote in message news:11*********************@i40g2000cwc.googlegro ups.com... WindowsIdentity.GetCurrent().Name will print NT AUTHORITY\NETWORK
SERVICE
User.Identity.Name will print myDomain/myUserName.

So I added read/write/change permissions to myDomain/myUserName -
didn't help.
Now, I don't have user called NT AUTHORITY\NETWORK SERVICE on my
domain, nor on the box that has the folder. Should I create one? On
domain?

May 10 '06 #9
I guess I was not clear enough.
ASP.NET is running on Windows2003 server. It's not domain controller.
I created virtual directory on that machine that points to network
directory.
It points to another computer on the network (W2000 server).
Because W2000 doesn't have NT AUTHORITY\NETWORK SERVICE I am not sure
how to resolve it...

May 11 '06 #10
That's quite a bit clearer, thanks.

If both machines are in the same domain, you can use impersonation for ASP.NET.

Create a domain account and

1. have ASP.NET run as that account
2. give that account the permissions it needs to the W2000 server's folder

See http://msdn2.microsoft.com/en-us/library/kwzs111e.aspx
for a list of ASP.NET 2.0 directories and the permissions the new ASP.NET account will require.

Review this checklist :
http://msdn.microsoft.com/library/de...aght000009.asp
for instructions on how to run ASP.NET with a custom service account.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<j_****@hotmail.com> wrote in message news:11**********************@j33g2000cwa.googlegr oups.com...
I guess I was not clear enough.
ASP.NET is running on Windows2003 server. It's not domain controller.
I created virtual directory on that machine that points to network
directory.
It points to another computer on the network (W2000 server).
Because W2000 doesn't have NT AUTHORITY\NETWORK SERVICE I am not sure
how to resolve it...

May 11 '06 #11
First of all it is quite challanging, at least for me....
It helped but didn't resolve my problem.
I created domain user, because I don't have ASP.NET 2.0, i followed
http://msdn.microsoft.com/library/de...SecNetht01.asp
those instructions to create a Custom Account to Run ASP.NET 1.1.
Then I modified web.config to
<identity impersonate="true" userName="DOMAIN\userName"
password="strongPass"></identity>
then I gave w2000 folder permissions to that accout.
Works!!!!!!
But, there is small problem.
I cannot modify web.config in my production web site.
So I think I should follow those steps:
Add domain user to connect to w2003 server. (HOW?)
Then create tokenHandle while calling LogonUser function
Then execute this code
Dim newId As New WindowsIdentity(tokenHandle)
Dim impersonatedUser As WindowsImpersonationContext =
newId.Impersonate()
Once executed, asp should run as that impersonated account.
Then I should be able to connect to w2000 server, do what I have to do,
then
impersonatedUser.Undo()
Does it make sense? Also how do I add domain user to w2003?
Thanks,

May 12 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Theerachet Pratoommanee | last post by:
This is error message I've got. Any suggestion would be appreciated. Server Error in '/WebDirectory' Application. ----------------------------------------------------------------------------...
4
by: Fabian von Romberg | last post by:
Hi, I have installed Sql Reporting Services on 2 machines, one is WIN 2000 PRO and the other one is WIN 2000 ADV. SERVER. When I try to access a report using the webbrowser, I get the following...
0
by: Goran | last post by:
Hi I have created a very simple ASP.Net application that only consists of a CrystalReports Viewer, that has been connected to a .rpt file. When the page is loaded in the browser, the following...
3
by: Shailesh Humbad | last post by:
I figured out what was causing the "Access is Denied" error when calling functions from referenced DLLs in my service. I've tried to be very detailed, so bear with me. It turns out that...
1
by: Duffman | last post by:
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...
3
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
2
by: stephen | last post by:
Hi, I am getting an Error "Access to the path...... is denied" Error. I have an web app and I am creating a log file to write the error info. If I have the absolute path...
1
by: cpajoe2001 | last post by:
I am having an issue and after searching around online for a day and half now and finding others with the same problem but yet no solution to my issue I am looking for help. What i have is ServerA...
8
by: Jeremy Ames | last post by:
I am trying to move an application from my system to a new test system. I really should have tried an easier program first, but I didn't really have a chance. My application was originally written in...
0
by: p.thorn.ru | last post by:
Hello, I am running db2 express-c 9.5 under linux (fedora 7), and my error log frequently shows messages like these: 2008-01-08-18.30.01.952964+180 I651334G1048 LEVEL: Error (OS) PID ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.