When connecting to a network share for which the current user (in my case, a network enabled service user) has no rights, name and password have to be provided.
I kn
One option that might work is using WindowsIdentity.Impersonate
(and change the thread principal) to become the desired user, like so. Back to p/invoke, though, I'm afraid...
Another cheeky (and equally far from ideal) option might be to spawn a process to do the work... ProcessStartInfo
accepts a .UserName
, .Password
and .Domain
.
Finally - perhaps run the service in a dedicated account that has access? (removed as you have clarified that this isn't an option).