0

I am writing an application in c#, which connects to other machines using remoting, and implants an executable on each machine and then executes it. Each machine creates a dedicated shared folder locally and then asynchronously tries to write to other machines' shared folder.

The problem is that when one machine tries to write to a shared folder of a different machine (in case they are not in the same domain), it fails. if I try to manually access from one machine to the other's shared folder, I'm being prompted for credentials, even though I can see that the shared folder gives full permissions to everyone.

Does anyone know how to solve this issue?

Thanks!

Steve
  • 8,469
  • 1
  • 26
  • 37
Haviva
  • 41
  • 3

1 Answers1

0

You can use the LogonUser API via P/Invoke to achieve this but you will need some mechanism for getting the users password (the user's keyboard is a good one for this ;) )

DllImport("advapi32.dll", SetLastError=true)]
   static extern bool LogonUser(
     string principal,
     string authority,
     string password,
     LogonTypes logonType,
     LogonProviders logonProvider,
     out IntPtr token);

void login(){
    bool result = LogonUser(
     "Alice", "ACME", // "ACME\Alice"
     pwd,
     LogonTypes.Batch,
     LogonProviders.Default,
     out token);
    if (result){
      //off you go
    }
 }
Fergal Moran
  • 4,525
  • 5
  • 39
  • 54
  • Thats the problem, I can't get user credentials, that's why I used shared folder, so I won't need it. Thanks. – Haviva Apr 29 '10 at 12:28
  • You can't access a shared folder without authenticating against it? The security implications are immense!! Your only other alternative would be to get your network admin to allow guest access to the share but that's kinda crazy.. – Fergal Moran Apr 29 '10 at 13:13