Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.NET doesn't have permission to access resource

Reply
Thread Tools

ASP.NET doesn't have permission to access resource

 
 
Brent Bigler
Guest
Posts: n/a
 
      12-17-2003
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


 
Reply With Quote
 
 
 
 
Morgan
Guest
Posts: n/a
 
      12-17-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Andrea D'Onofrio [MSFT]
Guest
Posts: n/a
 
      12-18-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Brent Bigler
Guest
Posts: n/a
 
      12-18-2003
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


 
Reply With Quote
 
Morgan
Guest
Posts: n/a
 
      12-20-2003
What OS are you running? If Win2K3, then I can't help...
"Brent Bigler" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PERL windows : "Windows cannot access the specified device, path orfile. You may not have the appropriate permission to access the item." guru Perl Misc 4 02-18-2009 04:46 PM
Resource expression to access resource located in library Heinrich Moser ASP .Net 1 03-27-2008 04:25 PM
Very annoying error: Access to the path is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity Jay ASP .Net 2 08-20-2007 07:38 PM
You may not have permission to use this resource! =?Utf-8?B?Um9nZXIgQw==?= Wireless Networking 1 02-26-2006 06:31 PM
Win98 box intermittantly getting 'No permission to access resource' error Remmy Computer Support 14 11-08-2005 08:56 AM



Advertisments