While trying to synchronize in Kentico, a user go this error:
Synchronization server error: Exception occurred: Access to the path 'C:\inetpub\wwwroot\92YOrg\CMSFiles\f3\f3ef02ff-84bf-4ccb-b815-b807d8fd35f6.jpg' is denied.
The thing is that the file in question is actually on the E drive instead of the C drive, as it says in the error. So why would Kentico think to look in the C drive? I'm guessing that there is a setting somewhere that needs to be changed, but I've had no luck finding it. Thanks for your time.
First, I'd go back to your website in IIS and actually determine where in the file system your website is mapped to.
Second, ensure you have proper permissions set on the directories in the file system.
Try to check System > File > Storage in Settings application.
Related
I am trying to copy a file using File.Copy() from my Windows Service (running as Network Service).
File.Copy(sourceFile, targetFile, true);
Trouble is, when the target is on a mapped network drive, I get an error:
Could not find a part of the path 'Z:\copiedfile.txt'
I found someone else who had this problem in 2006, but that thread has an unhappy ending: the OP gave up and found a workaround.
Have any solutions been discovered in the past 7 years?
Mappings are a per user session item, which means that while the mapping may exist on your desktop it does not exist in the service. You will need to use the UNC path instead to copy the file.
A service should not directly access local or network resources
through mapped drive letters. Additionally, a service should not use
the WNetXXXXXXX APIs to add, remove, or query any mapped drive
letters. Although the WNetXXXXXXX APIs may return successfully, the
results will be incorrect. A service (or any process that is running
in a different security context) that must access a remote resource
should use the Universal Naming Convention (UNC) name to access the
resource.
http://social.msdn.microsoft.com/Forums/vstudio/en-US/f9a702da-724b-4acc-a1bb-ac4d225838c8/copy-file-to-a-mapped-drive
http://support.microsoft.com/kb/180362/en-us
I know this has been asked before many times, but I have browsed tens of similar questions without help.
This error is showed when my asp.net 4.0 application tries to access a folder on my local drive, doing this:
XmlTextReader confReader = new XmlTextReader (filename);
while (confReader.Read()) // <- error line
{
// do something
}
In my web.config I have <Identity Impersonate="true">. For the folder I have assigned full-access to:
everyone
IIS APPPOOL\<custom apppoolname>
NETWORK SERVICE
Debugging the application, I can put up a watch which evaluates this call right before the incriminated line:
System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
the call shows the current user is IIS APPPOOL\<custom apppoolname>.
I'm on Windows 7 64bit with Sp1. I know it's probably something stupid but I have already spent an awful amount of time on this.
Edit:
The problem was in the variable "filename", which pointed to the right folder, but for a configuration problem the filename was missing (i.e. the content was "c:\data\" instead of "c:\data\file.xml"). The Asp.net error was actually confusing, since I had all the right permissions to access that folder. DJKRAZE pointed me to the right direction.
Here is what I would suggest checking
where are you declaring filename..?
Does the file even exist..?
do you have rights to that folder..? have you tried running VS as Admin..? do you have Virtual Directory setup for the web app..sounds like you have a few things configured improperly as well but can't really tell based on the code for starters this line System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
should yield your domain\\username or compuername\\username
Glad that FileName was all it was
IIS requires the path to a folder in the server machine has rights for Anonymous user login to access.
Make sure the user Anonymous has the rights to access the folder.
Ok so I believe I am doing something very easy here. I have written an ASP.NET web page and it is just trying to write to the local directory.
I am using the following code:
System.IO.File.WriteAllLines("log.txt", messages);
I am throwing the following exception.
Access to the path 'c:\windows\system32\inetsrv\log.txt' is denied.
My ASP.NET application sits in the following directory.
c:\inetpub\wwwroot\sites\mysite\
So I am confused as to why it is trying to write to c:\windows\system32\inetsrv\ directory when I am not supplying that directory itself.
I have tried changing the code to the following but it gives me the same error message with a new directory.
System.IO.File.WriteAllLines("c:\\inetpub\\wwwroot\\sites\mysite\log.txt", messages);
Edit 1
It was hard to accept an answer on this because everyone really helped me out a ton. I accepted tom_yes_tom's answer because he was the first to post his response which was the first half of my problem. The other half of my problem was related to hbrock's solution that Fabio pointed out.
Create the folder "C:\inetpub\wwwroot\sites\mysite\App_Data" and save your data there instead.
System.IO.File.WriteAllLines(Server.MapPath("~/App_Data/log.txt"))
If you absolutely must save it to the mysite directory, be aware of security ramifications of putting a log file there and set directory permissions appropriately. The user that IIS is running under needs to be able to read and write that directory.
Full qualifying path: System.Web.HttpContext.Current.Server
You're receiving "Access to the path 'c:\windows\system32\inetsrv\log.txt' is denied." when you execute System.IO.File.WriteAllLines("log.txt", messages) because c:\windows\system32\inetsrv is the directory where the IIS executable is located (w3wp.exe).
You have to use Server.MapPath so it gives you the physical path of your virtual directory.
Look which user is running your virtual directory's application pool, and give him write permissions on the folder of your virtual directory.
This should help:
To grant read, write, and modify permissions to a specific file
In Windows Explorer, locate and select the required file.
Right-click the file, and then click Properties.
In the Properties dialog box, click the Security tab.
On the Security tab, examine the list of users. If the Network Service account is not listed, add it.
In the Properties dialog box, click the Network Service user name, and in the Permissions for NETWORK SERVICE section, select the Read, Write, and Modify permissions.
Click Apply, and then click OK
information from: http://msdn.microsoft.com/en-us/library/ff647402.aspx#paght000015_fileaccess
I am installing some component in network location. At the time of uninstall, if network location is unavailable because remote machine is not on. setup is giving following error
Error 1606 could not access network location
Is there any way to suppress this error and continue the uninstallation process?
If the files on Network location(that is unavailable at the time) are not deleted then its ok for me.
To fix your issue you could try and set the component to Permanent ="yes" which will not un-install that component and in theory you should not get that error.
However personally I would re-think the implementation to get around adding files to the network location (maybe add the network files on first run of your application?).
I'm attempting to read a PDF from a UNC path, i.e. \10.32.16.24\repositories\repository0001\VOL00001\ktappb01_024655001_0.PDF
My virtual directory ASP.NET site is being run under IUSR_machine_name.
Has anonymous access enabled as well.
I gave IUSR_machine_name full rights to the UNC share and as I step through my ASP.NET page's code behind onto the File.OpenRead(filepath) method, it throws an exception: "Access to path \10.32.16.24\repositories\repository0001\VOL00001\ktappb01_024655001_0.PDF is denied".
I tried granting the ASPNET user full rights to the share as well with the same result.
At this point I'm completely lost for a resolution.
I'm running IIS6.
On both machines security eventlog, check what user has been denied access. It is most likely a different user.
I was able to find the user by logging it. I'd made a stupid error in my code that wasn't giving me the result I was assuming I was going to get.