|
| .NET security and Network Shares |
|
|
|
|
| Messages |
|
Related Types |
This message was discovered on microsoft.public.dotnet.framework.aspnet.security.
| Jim Thomas |
I have a site that needs to serve various images from a set of network shares. When a file is requested, backend C# code looks up the file in SQL server, then loads it from the path specified and returns it in the response object with the proper content type.
This all works fine as long as the file is located on a local drive. As soon as I change the SQL server entry to point to a file on a network share (which is mapped to a local drive letter), it fails. I get the following error:
System.IO.DirectoryNotFoundException: Could not find a part of the path "X:\test.jpg"
I have tried several things to get this to work. I have changed the ASP.NET process to run as system, and also as a specific user that I created. All to no avail.
It is running on a ASP.NET development machine, not under IIS 6. But, I'm not sure if that matters.
Any help would be greatly appreciated.
Thanks, Jim
|
|
|
| |
|
| |
| |
| Jim Thomas |
I have some more information about this problem:
The following is in one of my .aspx files.
try { FileIOPermission perm = new FileIOPermission (FileIOPermissionAccess.Read,@"X:\\"); perm.Demand(); s = (System.IO.Stream)File.OpenRead(name); } catch (Exception e) { string err = e.ToString(); }
The perm.Demand() call does not throw an exception, indicating that read accesss to the mapped drive (X:) is permitted. However, on the next line, the call to File.OpenRead throws a DirectoryNotFound exception as described in my previous post.
Can someone at Microsoft please help me explain this???
|
|
|
| |
|
| |
| |
| leo lin[MS] |
Hi Jim Thomas,
Can you give me more details about reproduce procedure?
I try to use normal C# application and visit network map drive, it is work correctly.
new FileIOPermission(FileIOPermissionAccess.Read , "somefile");
// Try to access a file try { fs = new FileStream("somefile", FileMode.OpenOrCreate); } catch (Exception e) { string err = e.ToString(); }
Best Regards
leolin
|
|
|
| |
|
|
| |
|
|
| |
| leo lin[MS] |
Hi Jim Thomas,
Can you give me more details about reproduce procedure?
I try to use normal C# application and visit network map drive, it is work correctly.
new FileIOPermission(FileIOPermissionAccess.Read , "somefile");
// Try to access a file try { fs = new FileStream("somefile", FileMode.OpenOrCreate); } catch (Exception e) { string err = e.ToString(); }
Best Regards
leolin
|
|
|
| |
|
| |
| |
| Jim Thomas |
I've attached a small file that reproduces the problem.
Thanks again, Jim
[Original message clipped]
|
|
|
| |
|
| |
| |
| leo lin[MS] |
It will be ASPNET user account (aspnet_wp.exe ) can't access network sharing resource. ASPNET is local account and it is not domain account.
There is KB Q317012 outlines the security settings for asp.net page.
He has several options:
1. Enabling Delegation.
2. machine.config
a. you can specify either localsystem, asp worker process account or a specific user account.
b. if you specify the asp work process account, you'll need to enable the guest account on the file server to have an
anonymous user access the share.
3. web.config - turn impersonation on or off and then based on the impersonated user provide access to the share.
INFO: Process and Request Identity in ASP.NET [aspnetkb]ID: Q317012
ASP.NET Does Not Work with ASPNET Account on Domain Controller[aspnetkb] ID: Q315158
Best Regards
leolin
|
|
|
| |
|
|
| |
|
|
| |
| Jim Thomas |
Sorry for the delay, I was on vacation...
Thanks for the response. This code is running in a .aspx file on my .NET development web server. This is some kind of an issue with ASP.NET security I think.
Thanks for your help, Jim
[Original message clipped]
|
|
|
| |
|
| |
| |
| Frank Tien |
Did someone solve this issue? Currently, I also have same problem, so what is the solution of this?
|
|
|
| |
|
| |
|
|
|
| |
| Frank Tien |
Did someone solve this issue? I have the same problem. Please post any possible work around solution. thx
-------------------------------- From: Frank Tien
|
|
|
| |
|
|
| |
|
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|