G
Guest
Hi
I have a small WinForms app that needs to copy files from a shared drive on
a network. If I connect to the mapped drive using Explorer, a password dialog
pops-up and I have to provide credentials with permission to access this
resource on the machine where it's hosted. This is once for each desktop
logon session (ie after every reboot). If I do this, my app can access the
network resource fine, but otherwise fails with permission errors.
As my app runs when Windows starts, I don't want to first connect to the
mapped drive each and every time.
I've found some C# code that allows me to impersonate a
domain/account/password context, but it won't work in the scenario I want. I
know the code works because it allows me to impersonate local accounts, just
not access the network resource. When run, the following error occurs:
"Error No: 1326 - Error: Logon failure: unknown user name or bad password."
However, I know the domain/account/password are all correct.
The code is based on Win32 API's LogonUser. Am I barking up the wrong tree?
Thanks
Ben
I have a small WinForms app that needs to copy files from a shared drive on
a network. If I connect to the mapped drive using Explorer, a password dialog
pops-up and I have to provide credentials with permission to access this
resource on the machine where it's hosted. This is once for each desktop
logon session (ie after every reboot). If I do this, my app can access the
network resource fine, but otherwise fails with permission errors.
As my app runs when Windows starts, I don't want to first connect to the
mapped drive each and every time.
I've found some C# code that allows me to impersonate a
domain/account/password context, but it won't work in the scenario I want. I
know the code works because it allows me to impersonate local accounts, just
not access the network resource. When run, the following error occurs:
"Error No: 1326 - Error: Logon failure: unknown user name or bad password."
However, I know the domain/account/password are all correct.
The code is based on Win32 API's LogonUser. Am I barking up the wrong tree?
Thanks
Ben