mattjohnsonpint/SimpleImpersonation

Trust relationship between this workstation and the primary domain failed

rhmiranda opened this issue · 1 comments

Hello,

In my tests I have access to a shared directory on the network, the credentials I use to access it are different from the ones I use on my PC. My code looks like this:

var credentials = new UserCredentials(domain, user, pass);
Impersonation.RunAsUser(credentials, LogonType.Interactive, () =>
{
File.Copy(FullPathAndFileName, FullPathDestiny);
});

But I always get the same error: Trust relationship between this workstation and the primary domain failed.

Can anyone help me how to solve this?
PS- If I remove the domain from the credentials I receive the invalid user or password msg, but through windows explorer I can access the share with these credentials.

Have you tried LogonType.Network ?