简体   繁体   English

经典ASP + IIS 7将文件写入网络驱动器

[英]Classic ASP + IIS 7 Writing a file to a network drive

I have Classic ASP 2 websites on an Windows 2008 IIS 7 install. 我在Windows 2008 IIS 7安装上有Classic ASP 2网站。 website1.com and website2.com. website1.com和website2.com。 Both are serving the same website from one folder: C:\\Webs\\website\\ 两者都在一个文件夹中提供相同的网站:C:\\ Webs \\ website \\

website1.com has been in operation for 6 years and in the app it can write files to a network share; website1.com已运营6年,可以在应用程序中将文件写入网络共享; \\wdc\\SharedFiles\\assets\\docs\\ All the proper permissions are set as it has been reading and writing files for years. \\ wdc \\ SharedFiles \\ assets \\ docs \\设置了所有适当的权限,因为它多年来已经读写文件。

I recently added website2.com. 我最近添加了website2.com。 The website is serving from the same diretory. 该网站来自同一目录。 I need it to be able to write to that same share. 我需要它能够写入相同的共享。 The problem is, website2.com gets "Write to file failed." 问题是,website2.com收到“写入文件失败”的消息。 and "Permission Denied" errors. 和“权限被拒绝”错误。

How is this possible? 这怎么可能?

I even mocked up a simple test. 我什至嘲笑了一个简单的测试。 Same error.: 同样的错误:

  Dim fso, objFile
  Set fso=Server.CreateObject("Scripting.FileSystemObject")
  Set objFile=fso.CreateTextFile("\\wdc\SharedFiles\assets\docs\test.txt")
  objFile.WriteLine("hello this is test")
  objFile.Close
  Set objFile=Nothing
  Set fso=Nothing

Any ideas? 有任何想法吗? I am pulling my hair out. 我正在拔头发。

I figured this out on my own. 我自己解决了这个问题。 So others can benefit, here it is: 这样其他人可以受益,这里是:

  1. In IIS go to the website (website2.com) node, then select "Authentication". 在IIS中,转到网站(website2.com)节点,然后选择“身份验证”。
  2. Make sure "Anonymous Authentication" is enabled and set it to a user. 确保启用了“匿名身份验证”并将其设置为用户。
  3. Then with the Explorer give that user read-and-write access to the share. 然后使用资源管理器为该用户提供对共享的读写访问权限。

Not sure if this will make a difference. 不知道这是否会有所作为。 The only difference in my code, really, is that I'm using server.mapPath to specify path. 实际上,代码中的唯一区别是,我使用的是server.mapPath来指定路径。

path = Server.MapPath ("\")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateTextFile(path & "\" & txtFileName, 2) '2 = for Writing
f.Write(txtFileContents)
f.close
set f=nothing

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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