简体   繁体   中英

Access to file is denied exception with asp.net impersonation

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.

在此处输入图片说明

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM