繁体   English   中英

同时模拟多个用户

[英]impersonate multiple users at the same time

我正在.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)一样工作new Impersonator(usr_name_target, domain_target, password_target)

它忘记了外部模仿。

有谁知道如何在不映射驱动器等情况下做到这一点?

您一次只能模拟一个用户,因此您当前的解决方案将不起作用。 基本上,您尝试连接到两个不同的网络资源。 您可以P /调用WNetAddConnection2函数以连接到不同域的网络资源并根据需要执行操作。 有关WNetAddConnection2的详细信息,请参见此处: https ://msdn.microsoft.com/zh-cn/library/windows/desktop/aa385413(v = vs.85).aspx

查看这篇文章,以了解您如何P /调用WNetAddConnection2: 如何在连接到网络共享时提供用户名和密码

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM