Windows服务无法复制到文件共享 [英] Windows service can't copy to file share

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

问题描述

我有一个窗口服务设置为从本地目录中的文件复制到Samba共享。

该服务通过UNC路径连接到服务器(即\的RemoteServer \ shareddir)。

我已经登录作为其下运行服务的用户,并且是能够同时复制文件和Samba共享创建文件,使用UNC路径。

但是,运行服务时,我收到了提示登录错误的IO异常。我已经在该设备上运行的过程监控,看服务,我可以看到它找到的UNC路径,但得到试图写入共享时登录错误。

这是使用普通的香草.NET System.IO.File.Copy电话。

我不明白的错误,因为在同一个用户登录的时候,我能够复制和创建文件的共享。

任何想法?

编辑:异常文本

  

在主处理循环错误   (DoWork的()):登录失败:未知   用户名或密码错误。

     

System.Exception的:错误的   MyService.ProcessExportTransferfileDirectories   和值:D:\出口,   \的RemoteServer \ intray,   D:\出口\档案--->   System.IO.IOException:登录失败:   未知的用户名或密码错误。

     

在   System.IO .__ Error.WinIOError(的Int32   错误code,字符串maybeFullPath)在   System.IO .__ Error.WinIOError()在   System.IO.File.Move(字符串   sourceFileName,串destFileName)
  在   MyService.Consumer.BusinessLogic.WmsFacade.MoveAndArchiveFile(字符串   sourceFolder,串targetFolder,   字符串archiveFolder,字符串   rootFolder,LogCategory logCategory,   LogCounter logCounter)---结束   内部异常堆栈跟踪---在   MyService.Consumer.BusinessLogic.WmsFacade.MoveAndArchiveFile(字符串   sourceFolder,串targetFolder,   字符串archiveFolder,字符串   rootFolder,LogCategory logCategory,   LogCounter logCounter)在   MyService.Consumer.BusinessLogic.WmsFacade.ProcessExportTransfer(IDictionary`2   fileDirectories)在   MyService.Core.TimedWorkerProvider.DoWork()

解决方案

它结束了一个权限问题

- 运行的服务为不同的用户,这是建立在Samba共享其运行没有任何问题,整个复制文件后。

还是不明白,为什么使用不同的帐户时,我可以复制/创建使用Windows资源管理器,但是当该服务在同一帐户下运行它不能在所有访问共享上的共享文件:(

I have a windows service set to copy files from a local directory to a samba share.

The service connects via a UNC path to the server (i.e. \remoteserver\shareddir).

I have logged in as the user under which the service is running, and was able to both copy files and create files on the samba share, using the UNC path.

However, when running the service I am getting io exceptions that suggest a login error. I have run process monitor on that box, watching the service and I can see it finding the UNC path but getting a login error when trying to write to the share.

This is using plain vanilla .net System.IO.File.Copy call.

I don't understand the errors, as when logged in under the same user I am able to copy and create files on the share.

Any ideas?

Edit: Exception text

Error in main processing loop (DoWork()): Logon failure: unknown user name or bad password.

System.Exception: Error on MyService.ProcessExportTransferfileDirectories and values: D:\Export, \RemoteServer\intray, D:\Export\Archive ---> System.IO.IOException: Logon failure: unknown user name or bad password.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.__Error.WinIOError() at System.IO.File.Move(String sourceFileName, String destFileName)
at MyService.Consumer.BusinessLogic.WmsFacade.MoveAndArchiveFile(String sourceFolder, String targetFolder, String archiveFolder, String rootFolder, LogCategory logCategory, LogCounter logCounter) --- End of inner exception stack trace --- at MyService.Consumer.BusinessLogic.WmsFacade.MoveAndArchiveFile(String sourceFolder, String targetFolder, String archiveFolder, String rootFolder, LogCategory logCategory, LogCounter logCounter) at MyService.Consumer.BusinessLogic.WmsFacade.ProcessExportTransfer(IDictionary`2 fileDirectories) at MyService.Core.TimedWorkerProvider.DoWork()

解决方案

It ended up being a permissions issue - after running the service as a different user that was setup on the samba share it ran without a problem, copying files across.

Still don't understand why when using a different account I could copy/create files on the share using windows explorer but when the service was running under the same account it couldn't access the share at all :(

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

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