In my environment I have the following machines on the same domain:
- hostnam1 (Windows 7 enterprise)
- hostnam2 (Windows 7 enterprise)
- hostnam3 (Windows Server 2012 R2 domain control)
I have a service which runs as Local system account on hostname1. The service runs in turn another process which inherit the Local system privileges and attempts to access the shared folder \\hostname2\ADMIN$. Both hostname1 and hostname2 are on the same domain.
I can access the shared folder without credentials from hostname1 or hostname3 using explorer but when the spawned process attempts to use the function WNetAddConnection2 to access the shared folder the error 1326 is returned ( ERROR_LOGON_FAILURE (0x52E) ). The same code works on another machine ( \\hostname3\ADMIN$ ). The credentials passed to the WNetAddConnection2 function are correct. The same code works if it's run by a local user as normal process.
How can I configure hostname2 to accept connections from Local system account ?
Using the syntax hostname2\username suggested by Harry Johnston I managed to get the WNetAddConnection2 function to work (return 0).
However when I call the function OpenSCManager like that:
OpenSCManager( "hostname2" , SERVICES_ACTIVE_DATABASE , SC_MANAGER_ENUMERATE_SERVICE);
I get the error 5 ( ERROR_ACCESS_DENIED (0x5) ).