java 访问映射的网络驱动器时出现问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/792376/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Problem in accessing a mapped network drive
提问by codeape
We have a problem in accessing content on a mapped network drive.
我们在访问映射网络驱动器上的内容时遇到问题。
We have a web application running on weblogic 8.1 on (Windows 2000 NT).
我们有一个在 weblogic 8.1 (Windows 2000 NT) 上运行的 web 应用程序。
The application retreives images from a mapped network drive and displays.
该应用程序从映射的网络驱动器中检索图像并显示。
Now we are moving our application onto a virtual machine (Windows 2003 SP1) hosted on Weblogic 10.3.
现在,我们将我们的应用程序移动到 Weblogic 10.3 上托管的虚拟机 (Windows 2003 SP1) 上。
But on this new set up even though the network drive is mapped and available on the machine, the application can't access it.
但是在这个新设置上,即使网络驱动器已映射并在机器上可用,应用程序也无法访问它。
Are there any specific settings for mapping network drives on virtual machines?
是否有用于在虚拟机上映射网络驱动器的特定设置?
Any help? Really struck with this.
有什么帮助吗?真的被这个打动了。
Thanks in advance.
提前致谢。
Jani.
贾尼。
回答by codeape
Suggest you start troubleshooting by making sure that the web application process has the necessary permissions to access the network share.
建议您通过确保 Web 应用程序进程具有访问网络共享所需的权限来开始故障排除。
Perhaps you need to change the account that the web application is running under to a Windows domain user? Perhaps the app is now running as LOCALSYSTEM (which only has local privileges).
也许您需要将运行 Web 应用程序的帐户更改为 Windows 域用户?也许该应用程序现在以 LOCALSYSTEM 身份运行(只有本地权限)。
If you cannot run the web app under a domain user account, you could try pass-through authentication: Create a local user on the web application server with the exact same user name and password as an account that can access the network share. Run the app under this local account.
如果您无法在域用户帐户下运行 Web 应用程序,您可以尝试传递身份验证:在 Web 应用程序服务器上创建一个本地用户,其用户名和密码与可以访问网络共享的帐户完全相同。在此本地帐户下运行应用程序。
Edit:
编辑:
If the web app is configured to connect to the network share using drive mappings, try using UNC paths instead. For instance change m:\directoryto \\server\share\directory
如果 Web 应用程序配置为使用驱动器映射连接到网络共享,请尝试改用 UNC 路径。例如更改m:\directory为\\server\share\directory
回答by Tim Robinson
The other gotcha -- apart from needing to have your service use a domain account -- is the fact that not all apps on a Windows server see the same set of network drive mappings. If you log into your server and set up a drive mapping by hand, your web app probably isn't going to notice it.
另一个问题——除了需要让您的服务使用域帐户之外——是事实上并非 Windows 服务器上的所有应用程序都能看到相同的网络驱动器映射集。如果您登录服务器并手动设置驱动器映射,您的 Web 应用程序可能不会注意到它。
The reason for this behaviour is that drive mappings on a Windows server are done on a per-session basis; Windows assigns one or more session IDs to server processes, and a different session ID to each interactive logon.
这种行为的原因是 Windows 服务器上的驱动器映射是在每个会话的基础上完成的;Windows 为服务器进程分配一个或多个会话 ID,并为每个交互式登录分配一个不同的会话 ID。
The safest way to do this would be to either:
最安全的方法是:
- Establish the drive mapping in code. I don't know anything about Weblogic, but you need to find the equivalent of the Windows WNetAddConnection2call.
- Or, switch to using UNC path names, thereby avoiding drive mappings.
- 在代码中建立驱动器映射。我对 Weblogic 一无所知,但您需要找到与 Windows WNetAddConnection2调用等效的方法。
- 或者,切换到使用 UNC 路径名,从而避免驱动器映射。
回答by Gary
The procedure for mapping network drives is the same for virtual and physical machines. I would suspect that the issue your are having has more to do with porting your application from Windows 2k/WebLogic 8.1 to Windows 2k3/WebLogic 10.3. The virtual part probably has little to do with it. For more help, we would need to know more details about the error you are seeing and how the application is configured to find your resources.
映射网络驱动器的过程对于虚拟机和物理机是相同的。我怀疑您遇到的问题与将应用程序从 Windows 2k/WebLogic 8.1 移植到 Windows 2k3/WebLogic 10.3 有更多关系。虚拟部分可能与它无关。如需更多帮助,我们需要了解有关您所看到的错误以及应用程序如何配置以查找您的资源的更多详细信息。

