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 :(