Windows Service无法访问网络共享 [英] Windows Service can't access network share

查看:126
本文介绍了Windows Service无法访问网络共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地计算机上运行Windows服务.它被配置为在NT AUTHORITY \ NETWORK SERVICE下运行.该程序访问同一子网中计算机上的网络共享驱动器.该共享目录将所有人"设置为完全控制".

I have a windows service running on my local machine. It's configured to run under NT AUTHORITY\NETWORK SERVICE. The program access a network shared drive on a computer in the same subnet. That shared directory has Everyone set to Full control.

我在File.Exists上得到False,但是文件存在.我确定这是一个权限问题.我忘记了什么吗?请注意,具有共享驱动器的计算机不在域中.

I'm getting False on File.Exists, but the file exists. I'm certain this is a permission issue. Am I forgetting anything? Note, the computer with the shared drive is not on a domain.

推荐答案

解决方案在这里找到: https://serverfault.com/questions/177139/windows-service-cant-access-网络共享

Solution was found here: https://serverfault.com/questions/177139/windows-service-cant-access-network-share

具有共享驱动器的计算机不在域中的事实是您的主要问题所在.为了使它起作用,您将必须配置Windows Service以特定用户身份运行,然后必须在远程系统上使用相同的密码创建相同的用户.这样可能会起作用.

The fact that the machine with the shared drive is not on a domain is where your main problem is. In order to get this to work you will have to configure the Windows Service to run as a specific user, and then you'll have to create an identical user on the remote system with the same password. It might work then.

问题源于以下事实:要登录到不在域中的计算机,您必须使用该计算机上存在的帐户登录该计算机.该计算机帐户绝对不会在该本地计算机上存在.通过使用相同的密码创建相同的用户,您也许可以使登录生效."

The problem stems from the fact that in order to log in to a machine not in a domain, you have to log into that machine using an account that exists on that machine. The machine account for something else definitely won't exist on that local machine. By creating an identical user with an identical password, you might be able get the login to work."

-sysadmin1138

-sysadmin1138

我在两台计算机上创建了相同的帐户,并且该服务帐户能够访问共享驱动器.将服务器放在同一域中是一个更好的解决方案,因此我正在努力做到这一点,但是这将同时起作用.

I created identical accounts on both machines and the service account was able to access the shared drive. Having the servers on the same domain is a better solution, so I'm working towards that, but this will work in the mean time.

这篇关于Windows Service无法访问网络共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆