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
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 callImpersonate
.There are also several projects (eg this one) to make the process a little easier.