Assume we have c:\DirA that can be read by User1 only, and c:\DirB that can be written by User2 only. Both credentials are know.
How can I copy files from DirA to DirB directly?
Assume we have c:\DirA that can be read by User1 only, and c:\DirB that can be written by User2 only. Both credentials are know.
How can I copy files from DirA to DirB directly?
假设进程在第一个用户的上下文中运行,运行LogonUser
以获取第二个用户的安全令牌。生成一个线程并调用ImpersonateLoggedOnUser
,将令牌作为参数传递。第二个线程将有权访问DirB
. 在第一个线程中读取数据,将它们传递给第二个线程并从那里写入。
如果您正在运行的用户具有备份或恢复权限,更简单的方法是使用OpenProcessToken
后跟AdjustTokenPrivileges
.