473,398 Members | 2,393 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,398 software developers and data experts.

ASP.NET doesn't have permission to access resource

The computer: W2K server, domain controller, Microsoft.Net Framework 1.1

========================
The error message:

Access to the path "c:\fanmail\newfiles" is denied
....

Exception Details: System.UnauthorizedAccessException: Access to the path
"c:\fanmail\newfiles" is denied

*(see below for Stack Trace)

========================

Fixes tried (but didn't work):

1. Added ASPNET account to c:\fanmail\newfiles and granted full permission
to resource;

2. Added ASPNET to Administrator group;

3. Changed machine.config processModel username setting to "SYSTEM";

4. Changed machine.config processModel username setting to "{Domain}\ASPNET"
along with the password setting to the appropriate password;

5. Sacrificed three chickens and a goat (in theory).

=======================

Most of the articles I've read say it's simply a permissions problem, like
the error reports. But it doesn't seem that any kind of permission changing
on the resource works. Anything else I should try?

Thanks for any help!

--Brent

----------------------------------------------------------------------------
-
The code class giving me the problems (from clsFTP, downloaded from
someplace on the Web)

===================================
Public Sub DownloadFile(ByVal sFileName As String, _
ByVal sLocalFileName As String, _
ByVal bResume As Boolean)
Dim st As Stream
Dim output As FileStream
Dim cSocket As Socket
Dim offset, npos As Long

If (Not (m_bLoggedIn)) Then
Login()
End If

SetBinaryMode(True)

If (sLocalFileName.Equals("")) Then
sLocalFileName = sFileName
End If

If (Not (File.Exists(sLocalFileName))) Then
st = File.Create(sLocalFileName) '<----Error here, I presume
st.Close()
End If

output = New FileStream(sLocalFileName, FileMode.Open)
cSocket = CreateDataSocket()
offset = 0

If (bResume) Then
offset = output.Length

If (offset > 0) Then
SendCommand("REST " & offset)
If (m_iRetValue <> 350) Then
'throw new IOException(reply.Substring(4));
'Some servers may not support resuming.
offset = 0
End If
End If

If (offset > 0) Then
npos = output.Seek(offset, SeekOrigin.Begin)
End If
End If

SendCommand("RETR " & sFileName)

If (Not (m_iRetValue = 150 Or m_iRetValue = 125)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If

Do While (True)
m_aBuffer.Clear(m_aBuffer, 0, m_aBuffer.Length)
m_iBytes = cSocket.Receive(m_aBuffer, m_aBuffer.Length, 0)
output.Write(m_aBuffer, 0, m_iBytes)

If (m_iBytes <= 0) Then
Exit Do
End If
Loop

output.Close()
If (cSocket.Connected) Then
cSocket.Close()
End If

ReadReply()
If (Not (m_iRetValue = 226 Or m_iRetValue = 250)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If

End Sub
===========================

Stack Trace:

[UnauthorizedAccessException: Access to the path "c:\FanMail\NewFiles" is
denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean
bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize) +44
clsFTP.DownloadFile(String sFileName, String sLocalFileName, Boolean
bResume) +120
clsFTP.DownloadFile(String sFileName, String sLocalFileName) +13
ASP.test_aspx.Page_Load() in C:\ClientsWeb\test.aspx:20
System.Web.Util.ArglessEventHandlerDelegateProxy.C allback(Object sender,
EventArgs e) +10
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
Nov 18 '05 #1
4 1723
Have you given the IUSR_<MachineName> account access to the folder? Had a
similar issue not to long ago, seems that the ASPNet account isn't enough
and wound up having to give access to the folder to the IUSR_<MachineName>
account.

"Brent Bigler" <bb*****@yahoo.com> wrote in message
news:uS**************@tk2msftngp13.phx.gbl...
The computer: W2K server, domain controller, Microsoft.Net Framework 1.1

========================
The error message:

Access to the path "c:\fanmail\newfiles" is denied
...

Exception Details: System.UnauthorizedAccessException: Access to the path
"c:\fanmail\newfiles" is denied

*(see below for Stack Trace)

========================

Fixes tried (but didn't work):

1. Added ASPNET account to c:\fanmail\newfiles and granted full permission
to resource;

2. Added ASPNET to Administrator group;

3. Changed machine.config processModel username setting to "SYSTEM";

4. Changed machine.config processModel username setting to "{Domain}\ASPNET" along with the password setting to the appropriate password;

5. Sacrificed three chickens and a goat (in theory).

=======================

Most of the articles I've read say it's simply a permissions problem, like
the error reports. But it doesn't seem that any kind of permission changing on the resource works. Anything else I should try?

Thanks for any help!

--Brent

-------------------------------------------------------------------------- -- -
The code class giving me the problems (from clsFTP, downloaded from
someplace on the Web)

===================================
Public Sub DownloadFile(ByVal sFileName As String, _
ByVal sLocalFileName As String, _
ByVal bResume As Boolean)
Dim st As Stream
Dim output As FileStream
Dim cSocket As Socket
Dim offset, npos As Long

If (Not (m_bLoggedIn)) Then
Login()
End If

SetBinaryMode(True)

If (sLocalFileName.Equals("")) Then
sLocalFileName = sFileName
End If

If (Not (File.Exists(sLocalFileName))) Then
st = File.Create(sLocalFileName) '<----Error here, I presume
st.Close()
End If

output = New FileStream(sLocalFileName, FileMode.Open)
cSocket = CreateDataSocket()
offset = 0

If (bResume) Then
offset = output.Length

If (offset > 0) Then
SendCommand("REST " & offset)
If (m_iRetValue <> 350) Then
'throw new IOException(reply.Substring(4));
'Some servers may not support resuming.
offset = 0
End If
End If

If (offset > 0) Then
npos = output.Seek(offset, SeekOrigin.Begin)
End If
End If

SendCommand("RETR " & sFileName)

If (Not (m_iRetValue = 150 Or m_iRetValue = 125)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If

Do While (True)
m_aBuffer.Clear(m_aBuffer, 0, m_aBuffer.Length)
m_iBytes = cSocket.Receive(m_aBuffer, m_aBuffer.Length, 0)
output.Write(m_aBuffer, 0, m_iBytes)

If (m_iBytes <= 0) Then
Exit Do
End If
Loop

output.Close()
If (cSocket.Connected) Then
cSocket.Close()
End If

ReadReply()
If (Not (m_iRetValue = 226 Or m_iRetValue = 250)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If

End Sub
===========================

Stack Trace:

[UnauthorizedAccessException: Access to the path "c:\FanMail\NewFiles" is
denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) +44
clsFTP.DownloadFile(String sFileName, String sLocalFileName, Boolean
bResume) +120
clsFTP.DownloadFile(String sFileName, String sLocalFileName) +13
ASP.test_aspx.Page_Load() in C:\ClientsWeb\test.aspx:20
System.Web.Util.ArglessEventHandlerDelegateProxy.C allback(Object sender, EventArgs e) +10
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731

Nov 18 '05 #2
Have you turned on impersonate in .config file? If yes, your web code run
under the the authenticated user of IIS; then you have configured the
Anonymous access you must add the permission for the account configured in
IIS (IUSR_machinename is the default on II5). Else if you have configured
the basic or windows integrated, you must add the permission for the
requester user.
I think that add a simple code the write the process identity could help you
to troubleshoot what's happens:
Response.Write("Identity: " +
System.Security.Principal.WindowsIdentity.GetCurre nt.Name)

HtH,
Andrea

--
This posting is provided "AS IS" with no warranties, and confers no rights.

"Brent Bigler" <bb*****@yahoo.com> wrote in message
news:uS**************@tk2msftngp13.phx.gbl...
The computer: W2K server, domain controller, Microsoft.Net Framework 1.1

========================
The error message:

Access to the path "c:\fanmail\newfiles" is denied
...

Exception Details: System.UnauthorizedAccessException: Access to the path
"c:\fanmail\newfiles" is denied

*(see below for Stack Trace)

========================

Fixes tried (but didn't work):

1. Added ASPNET account to c:\fanmail\newfiles and granted full permission
to resource;

2. Added ASPNET to Administrator group;

3. Changed machine.config processModel username setting to "SYSTEM";

4. Changed machine.config processModel username setting to "{Domain}\ASPNET" along with the password setting to the appropriate password;

5. Sacrificed three chickens and a goat (in theory).

=======================

Most of the articles I've read say it's simply a permissions problem, like
the error reports. But it doesn't seem that any kind of permission changing on the resource works. Anything else I should try?

Thanks for any help!

--Brent

-------------------------------------------------------------------------- -- -
The code class giving me the problems (from clsFTP, downloaded from
someplace on the Web)

===================================
Public Sub DownloadFile(ByVal sFileName As String, _
ByVal sLocalFileName As String, _
ByVal bResume As Boolean)
Dim st As Stream
Dim output As FileStream
Dim cSocket As Socket
Dim offset, npos As Long

If (Not (m_bLoggedIn)) Then
Login()
End If

SetBinaryMode(True)

If (sLocalFileName.Equals("")) Then
sLocalFileName = sFileName
End If

If (Not (File.Exists(sLocalFileName))) Then
st = File.Create(sLocalFileName) '<----Error here, I presume
st.Close()
End If

output = New FileStream(sLocalFileName, FileMode.Open)
cSocket = CreateDataSocket()
offset = 0

If (bResume) Then
offset = output.Length

If (offset > 0) Then
SendCommand("REST " & offset)
If (m_iRetValue <> 350) Then
'throw new IOException(reply.Substring(4));
'Some servers may not support resuming.
offset = 0
End If
End If

If (offset > 0) Then
npos = output.Seek(offset, SeekOrigin.Begin)
End If
End If

SendCommand("RETR " & sFileName)

If (Not (m_iRetValue = 150 Or m_iRetValue = 125)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If

Do While (True)
m_aBuffer.Clear(m_aBuffer, 0, m_aBuffer.Length)
m_iBytes = cSocket.Receive(m_aBuffer, m_aBuffer.Length, 0)
output.Write(m_aBuffer, 0, m_iBytes)

If (m_iBytes <= 0) Then
Exit Do
End If
Loop

output.Close()
If (cSocket.Connected) Then
cSocket.Close()
End If

ReadReply()
If (Not (m_iRetValue = 226 Or m_iRetValue = 250)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If

End Sub
===========================

Stack Trace:

[UnauthorizedAccessException: Access to the path "c:\FanMail\NewFiles" is
denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) +44
clsFTP.DownloadFile(String sFileName, String sLocalFileName, Boolean
bResume) +120
clsFTP.DownloadFile(String sFileName, String sLocalFileName) +13
ASP.test_aspx.Page_Load() in C:\ClientsWeb\test.aspx:20
System.Web.Util.ArglessEventHandlerDelegateProxy.C allback(Object sender, EventArgs e) +10
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731

Nov 18 '05 #3
Thanks for both your replies!

I added the IUSR account to the resource with no luck. I also checked to see
which identity is being used via Response.Write("Identity: " +
System.Security.Principal.WindowsIdentity.GetCurre nt.Name + "<br/>")

(clever idea!) and found that it's the ASPNET user. That user has all the
permissions in the world, aside from being an Administrator. I really am
stumped!

--Brent
Nov 18 '05 #4
What OS are you running? If Win2K3, then I can't help... ;)
"Brent Bigler" <bb*****@yahoo.com> wrote in message
news:uS**************@tk2msftngp13.phx.gbl...
The computer: W2K server, domain controller, Microsoft.Net Framework 1.1

========================
The error message:

Access to the path "c:\fanmail\newfiles" is denied
...

Exception Details: System.UnauthorizedAccessException: Access to the path
"c:\fanmail\newfiles" is denied

*(see below for Stack Trace)

========================

Fixes tried (but didn't work):

1. Added ASPNET account to c:\fanmail\newfiles and granted full permission
to resource;

2. Added ASPNET to Administrator group;

3. Changed machine.config processModel username setting to "SYSTEM";

4. Changed machine.config processModel username setting to "{Domain}\ASPNET" along with the password setting to the appropriate password;

5. Sacrificed three chickens and a goat (in theory).

=======================

Most of the articles I've read say it's simply a permissions problem, like
the error reports. But it doesn't seem that any kind of permission changing on the resource works. Anything else I should try?

Thanks for any help!

--Brent

-------------------------------------------------------------------------- -- -
The code class giving me the problems (from clsFTP, downloaded from
someplace on the Web)

===================================
Public Sub DownloadFile(ByVal sFileName As String, _
ByVal sLocalFileName As String, _
ByVal bResume As Boolean)
Dim st As Stream
Dim output As FileStream
Dim cSocket As Socket
Dim offset, npos As Long

If (Not (m_bLoggedIn)) Then
Login()
End If

SetBinaryMode(True)

If (sLocalFileName.Equals("")) Then
sLocalFileName = sFileName
End If

If (Not (File.Exists(sLocalFileName))) Then
st = File.Create(sLocalFileName) '<----Error here, I presume
st.Close()
End If

output = New FileStream(sLocalFileName, FileMode.Open)
cSocket = CreateDataSocket()
offset = 0

If (bResume) Then
offset = output.Length

If (offset > 0) Then
SendCommand("REST " & offset)
If (m_iRetValue <> 350) Then
'throw new IOException(reply.Substring(4));
'Some servers may not support resuming.
offset = 0
End If
End If

If (offset > 0) Then
npos = output.Seek(offset, SeekOrigin.Begin)
End If
End If

SendCommand("RETR " & sFileName)

If (Not (m_iRetValue = 150 Or m_iRetValue = 125)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If

Do While (True)
m_aBuffer.Clear(m_aBuffer, 0, m_aBuffer.Length)
m_iBytes = cSocket.Receive(m_aBuffer, m_aBuffer.Length, 0)
output.Write(m_aBuffer, 0, m_iBytes)

If (m_iBytes <= 0) Then
Exit Do
End If
Loop

output.Close()
If (cSocket.Connected) Then
cSocket.Close()
End If

ReadReply()
If (Not (m_iRetValue = 226 Or m_iRetValue = 250)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If

End Sub
===========================

Stack Trace:

[UnauthorizedAccessException: Access to the path "c:\FanMail\NewFiles" is
denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) +44
clsFTP.DownloadFile(String sFileName, String sLocalFileName, Boolean
bResume) +120
clsFTP.DownloadFile(String sFileName, String sLocalFileName) +13
ASP.test_aspx.Page_Load() in C:\ClientsWeb\test.aspx:20
System.Web.Util.ArglessEventHandlerDelegateProxy.C allback(Object sender, EventArgs e) +10
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731

Nov 18 '05 #5

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

Similar topics

0
by: Phil Powell | last post by:
I am having trouble retrieving URLs using curl for PHP whereby the URL requires a cookie to produce proper data. I wrote a wrapper class called Timer that will time the execution/download of a...
11
by: Wayne Wengert | last post by:
I am using VS.NET 2003, VB.NET, ADO.NET and an Access 2000 database. I want to display a list of all tables in an Access database. I want to put that list of table names in a listbox so the user...
12
by: Russ | last post by:
Hello. My new dev machine is running XP Pro. In the past all equipment has only used Windows 2000. I have had a lot of problems getting my projects up and running on the new machine. The current...
3
by: Chua Wen Ching | last post by:
Hi there, I had applied this security permissions in my class library based on fxcop standards. Before namespace: using System.Runtime.InteropServices; using System.Security.Permissions;
0
by: Jeremy | last post by:
I have an ASP.net application which needs to retreive images from multiple remote machines. It is reterieveing images generated by a web cam service on those machines. All of these machines,...
9
by: Sachin | last post by:
Hi All, I have installed an ASP.NET application under a web site. ASP.NET application uses an Impersonation Account, specified in Web.Config. Authentication mode is set to Windows and...
0
by: beachboy | last post by:
I have moving the application from windows 2000 to windows 2003, that application is using .net framework ver 1.1 and have their own COM library to do a specify task. I have registed on "COM+...
1
by: Snolly | last post by:
Hi all, I am using the open source dojo toolkit v .4.3 (I know it's old but can't upgrade). I have a page with an iframe in it. When the page loads, the iframe is pointing at a local resource...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.