使用 asp.net 模拟访问文件被拒绝异常

发布于 2025-01-07 21:07:24 字数 576 浏览 6 评论 0原文

我正在尝试使用以下 c# 代码访问文件,但是当我尝试执行代码时,遇到异常,提示访问路径 @"\MAHESH-PC\D$\temp\CloudURL.txt 被拒绝。

在此处输入图像描述

模拟 imp = new Impersonation("MAHESH-PC", "mahesh", "welcome"); File.Copy(@"\MAHESH-PC\D$\temp\CloudURL.txt", @"C:\temp\CloudURL.txt", true);

我已授予对 c: 驱动器中的临时文件夹和 d: 驱动器中的另一个临时文件夹的所有访问权限

输入图像描述这里

我已经在 IIS 中启用了模拟,即使这样我也遇到了访问被拒绝的异常,请问我是否可以知道我应该实施的任何其他设置才能使其正常工作。

在此处输入图像描述

I am trying to access the files with following c# code, but when i try to execute the code i am encountered with exception saying access to path @"\MAHESH-PC\D$\temp\CloudURL.txt is denied .

enter image description here

Impersonation imp = new Impersonation("MAHESH-PC", "mahesh", "welcome");
File.Copy(@"\MAHESH-PC\D$\temp\CloudURL.txt", @"C:\temp\CloudURL.txt", true);

I have given all the access rights to both the temp folders one in the c: drive and other in the d: drive

enter image description here

I have enabled the Impersonation in the IIS , even then i am getting access denied exception , please can i know is their any other settings i should implement to make this working.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月如刀 2025-01-14 21:07:24

您的 web.config 中是否启用了模拟?我并不肯定,但我认为在 IIS 中启用模拟不会对您的网站的模拟产生任何影响。如果没有,请打开它,或授予应用程序池身份对两个目录的读/写访问权限,看看是否有帮助。

另外,请仔细检查您的文件夹系统的安全性。您似乎授予了每个人对该共享的读/写访问权限,但如果您导航到路径 \pc\drive$\ ,那么它可能依赖于文件系统安全性,而不是文件夹共享本身的安全性。有道理吗?

Is impersonation enabled in your web.config? I'm not positive but I wouldn't think enabling impersonation in IIS has any affect on the impersonation of your site. If not, turn it on, or grant the app pool identity read/write access to both your directories and see if that helps.

Also, double check your folder system security. It appears you granted everyone read/write access to the share, but if you're navigating to the path \pc\drive$\ then it may be relying on file system security and not the security on the folder share itself. Make sense?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文