I'm making a service in .net that copy files from one domain (Domain A) to other domain (Domain B) both domain need credentials in order to connect to them so i'm using impersonation.
using (new Impersonator(usr_name_source, domain_source, password_source))
the impersonation is working only for one domain each time, so actually i cannot work how to impersonate both domains at the same time in order to copy the files so i'm trying this:
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);
}
}
but its not working as when i impersonate the inside new Impersonator(usr_name_target, domain_target, password_target)
it forget the outer impersonation.
does anyone has any idea how to do that without mapping drives etc...?