.Net 网站创建目录到远程服务器访问被拒绝
我有一个创建目录的网络应用程序。 该应用程序在 Web 服务器上创建目录时工作正常,但在尝试在远程文件服务器上创建目录时则无法工作。
文件服务器和网络服务器位于同一域中。 我在我们的域“DOMAIN\aspnet”中创建了一个本地用户。本地用户在两台服务器上。
我正在域用户下运行我的 .Net 应用程序池。我还尝试在 web.config 中使用 windows 模拟在域用户下运行。
我已验证域用户对远程目录具有完全控制权。为了调试这个问题,我还授予“每个人”对远程目录的完全控制权。
为了调试这个问题,我还将域用户添加到了管理员组。
我在网络服务器上有一个简单的 .net 测试页面来测试这一点。 通过测试页,我可以读取文件服务器上的目录并获取其中所有内容的列表。
我无法上传文件或在文件服务器上创建目录。
这是有效的代码:
var path = @"\\fileserver\images\";
var di = new DirectoryInfo(path);
foreach (var d in di.GetDirectories())
{
Response.Write(d.Name);
}
这是无效的代码:
path = Path.Combine(path, "NewDirectory");
Directory.CreateDirectory(path);
这是我收到的错误: 对路径“\fileserver\images\NewDirectory”的访问被拒绝。
我对此很困惑。有什么想法吗?
I have a web application that creates directories.
The application works fine when creating a directory on the web server, however, it does not work when it tries to create a directory on our remote fileserver.
The fileserver and the webserver are in the same domain.
I have created a local user in our domain, "DOMAIN\aspnet". The local user is on both servers.
I am running my .Net app pool under the domain user. I have also tried using windows impersonate in the web.config to run under the domain user.
I have verified that the domain user has full control to the remote directory. In an effort to debug this I have also given the "everyone" full control to the remote directory.
In an effort to debug this I have also added the domain user to the administrators group.
I have a simple .net test page on the web server to test this.
Through the test page I am able to read the directory on the file server and get a list of everything in it.
I am not able to upload files or to create directories on the file server.
Here's code that works:
var path = @"\\fileserver\images\";
var di = new DirectoryInfo(path);
foreach (var d in di.GetDirectories())
{
Response.Write(d.Name);
}
Here's code that doesn't work:
path = Path.Combine(path, "NewDirectory");
Directory.CreateDirectory(path);
Here's the error I'm getting:
Access to the path '\fileserver\images\NewDirectory' is denied.
I'm pretty stuck on this. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查服务器/站点的信任级别。如果您的运行速度低于完全信任,那么您可能需要修改您的
FileIOPermission
设置:$AppDir$
宏值将扩展到您的网站所在的文件夹。可以通过用分号分隔来附加其他路径。您需要编辑的文件将由
C 中的主
,假设您正在运行 .NET 2.0。web.config
文件中的
设置指向:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIGCheck the trust level of the server/site. If you're running at less than Full Trust then you may need to modify your
FileIOPermission
setting:The
$AppDir$
macro value expands to the folder your website resides in. You can append additional paths by separating them with semi-colons.The file you need to edit will be pointed at by the
<trust level=.../>
setting in the masterweb.config
file inC:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG
, presuming that you're running .NET 2.0.该问题最终成为路径问题。
\fileserver\images\ 映射到 h:\files\http\images
该服务有权访问 H 处的驱动器,但没有共享权限。
The issue ended up being a path issue.
\fileserver\images\ was mapped to h:\files\http\images
The service had permissions to the drive at H, but not the share.