使用 asp.net 模拟访问文件被拒绝异常
我正在尝试使用以下 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 .
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
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 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?