Impersonated User unable to access shared drive

1.3k views Asked by At

I have a windows service that needs to periodically impersonate a user to gain access to a network shared drive.

I am able to impersonate the user without issue; however when i try to access the shared drive via code I get the following error:

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator`1.CommonInit()
at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
at System.IO.DirectoryInfo.InternalGetFiles(String searchPattern, SearchOption searchOption)
at System.IO.DirectoryInfo.GetFiles(String searchPattern)

From what i have read this is most likely a permissions issue, but i have yet to find a solution that works. I can log into the server that runs the windows service as the user in question and navigate via explorer directly to the path and from there I can copy, paste and delete files.

I guess I am a bit confused as to how to proceed and any suggestions would be appreciated.

Update The windows service and the user to be impersonated are on the same server (A) the shared network drive is located on a separate server (B). Also this isn't a "run as" scenario as I am not trying to run any files, simply copy from B to A

0

There are 0 answers