Write to a Directory as a Specific User on a Different Domain

有些话、适合烂在心里 提交于 2020-01-15 12:06:08

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/1598898/write-to-a-directory-as-a-specific-user-on-a-different-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!