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

ASP.NET doesn't have permission to access resource

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.