I am having a problem accessing a mapped drive in ColdFusion. I have \\server\files\sharing
mapped to z:\
. If I run this code, it says the directory exists for the full path but not for the mapped one:
<cfscript>
fullPath = "\\server\files\sharing\reports";
mappedPath = "z:\reports";
WriteOutput("fullPath exists: #DirectoryExists(fullPath)#<br/>"); //YES
WriteOutput("mappedPath exists: #DirectoryExists(mappedPath)#"); //NO
</cfscript>
I have done some Googling and have found a few people with the same problem, but the solution was always to use the full path. Is there a reason ColdFusion wouldn't be able to see or access the mapped drive? And if so, are there any workarounds (maybe a system call t开发者_开发问答o get the full path of the mapped drive)?
The reason why ColdFusion does not have access to the mapped drive is because it runs as a service in Windows.
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.
That was pulled from the following knowledge-base article: http://support.microsoft.com/kb/180362
You may be able to change the service to run as an individual user that has the drives mapped (I haven't checked if that works, but it might), but you should be using the UNC path instead of the mapped drive.
精彩评论