0

I am working on a program for my application which needs to copy over some files from machine A to to C$ share of Machine B.This is specific to machines in a same workgroup. I did some good research and found that if i access Machine B registry remotely and set "LocalAccountTokenFilterPolicy" to 1 then i can access C$ share. But the code snippet below to open the registry is giving me access denied exception.I am interested to know is there any other approach to access the C$ share if i have the Admin account details and machine-name of the machine B.I figured out that the editing registry is not really possible in workgroup.

code snippet:

var key = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "XXXX");
Console.WriteLine("Before OpenSubKey");
var key2 = key.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\System\LocalAccountTokenFilterPolicy");
Steve
  • 213,761
  • 22
  • 232
  • 286
  • The most practical solution would be to go around to each of the machines (or use Remote Desktop, if that's enabled) and change the registry setting by hand. It might in principle be possible to automate that, but it would almost certainly be far more trouble than it's worth. (You only have to do it once, after all.) – Harry Johnston Aug 07 '16 at 10:01

1 Answers1

0

Use impersonation. You can't access remote machine as local user if you don't have any permissions on remote machine. If you start app normally, it will run as local user and will try to query remote machine with local crediantials. Simple as that.

Lots of info and good examples here.

Community
  • 1
  • 1
Vytautas Plečkaitis
  • 851
  • 1
  • 13
  • 19
  • Thank you for the solution but i already included impersonation and it did not work. Since the machines are in workgroup and UAC is enabled by default so i am not having any luck with the registry. – NerdforLife Aug 07 '16 at 03:12
  • Might want to look [here](http://stackoverflow.com/questions/1566547/how-to-read-remote-registry-keys) - at second answer of [etoisarobot](http://stackoverflow.com/users/97736/etoisarobot). He manages to do that via WMI without changing permissions. – Vytautas Plečkaitis Aug 08 '16 at 08:10