【发布时间】:2015-08-20 08:21:42
【问题描述】:
我正在 .net 中创建一项服务,将文件从一个域(域 A)复制到另一个域(域 B) 两个域都需要凭据才能连接到它们,所以我正在使用模拟。
using (new Impersonator(usr_name_source, domain_source, password_source))
模拟每次仅适用于一个域,因此实际上我无法同时模拟两个域以复制文件 所以我正在尝试这个:
using (new Impersonator(usr_name_source, domain_source, password_source))//server authentication
{
using (new Impersonator(usr_name_target, domain_target, password_target))//server authentication
{
DeleteOldFiles(targetPath);
Copy(sourcePath, targetPath);
}
}
但是当我模仿内部new Impersonator(usr_name_target, domain_target, password_target)时它不起作用
它忘记了外部模仿。
有没有人知道如何在不映射驱动器等的情况下做到这一点...?
【问题讨论】:
-
为什么需要做嵌套模拟?正如您发现的那样,您不能同时成为两个用户。为什么不分两步进行操作呢?你不能登录到源目录并在本地复制文件。登录到目标目录并将文件从本地复制到目标?
-
也许通过创建多个线程......
-
是的,我可以,但我在这里谈论的是大文件 - 我不想要中间存储,我想直接从 A 移动到 B。我也更喜欢不使用线程...
标签: c# .net impersonation