views:

33

answers:

1

Hi All,

I am wondering, how would one write a file (say for instance, from a Console Application in a scheduled task) to another computer on a different domain? How would one set the Username and Password, such as with the "Log on to..." dialog to authenticate?

Couple of prerequisites exist, obviously:

  • The machines can see each other across the domains, however they need to authenticate
  • You know the login details
  • The username you would log in with has the appropriate permissions to write

Anyone have any idea?

Thanks,

Kyle

+2  A: 

The approach here is to use Impersonation. Have a look here for a straightforward how-to.

Essentially, you need to obtain a handle to the user token (usually using LogonUser), and then call Impersonate.

There are also several projects (eg this one) to make the process a little easier.

Nader Shirazie
Thanks a lot. Always wanted to learn Impersonation and never got around to it, I didn't know it was so simple. Thanks again Nader.
Kyle Rozendo
Np. Have fun with it :)
Nader Shirazie