Remote OpenSCManager fails with access denied
问题 I am attempting to control a service on a remote machine using the following code: // Error checking omitted for brevity HANDLE hToken = NULL; // user = username with no domain specification // domain = targetmachine when targetting computer outside of domain LogonUser(user, domain, password, LOGON32_LOGON_NEW_CREDENTIALS, LOGON32_PROVIDER_WINNT50, &hToken); ImpersonateLoggedOnUser(hToken); SC_HANDLE hSc = OpenSCManager(targetmachine, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ALL_ACCESS); This