Closed bluebaroncanada closed 3 years ago
I don't think that works if the login would fail on the local computer (i.e. local computer is in a different domain from the target computer, so the credentials given would fail to login to the local computer). Please educate me if I am wrong :)
I don't think that you have to use WNetAddConnection2. Which means you don't have to check for open connections either. Another thing: You shouldn't support non-unicode.
Instead consider this: LogonUserW(username, domain, password, LOGON32_LOGON_NEW_CREDENTIALS, LOGON32_PROVIDER_WINNT50, &token);
if(!ImpersonateLoggedOnUser(token)) return GetLastError();
CopyFileW(local_file, remote_file, false);