I have a Windows form app. It switches identity by calling LogonUser, then
calls WindowsIdentity.Impersonate. While I'm impersonating, I'd like to copy
a file from my machine to another machine in the domain via
system.IO.File.Copy. The impersonation works just fine, however, the copy
fails with "access to the path <target path> is denied" exception.

If I attempt to copy the file to a different directory on the same machine
it works.  If I log on to my machine as the impersonated user, and copy the
file to a different machine via Windows Explorer, it works.

Originally I was calling LogonUser with LOGON32_LOGON_NETWORK (3).  Someone
suggested switching to LOGON32_LOGON_INTERACTIVE.  When I tried that, the
Impersonate() failed with an exception "Unable to impersonate user".

I'm running on Win2K.  The original account has been granted the "Act as
part of the operating system" user right.  The impersonated account has
been granted the "Log on locally" right on the source machine (ie. copy
from) and the "Access this computer from the network" on the target machine
(ie. copy to).

Is there a way I can copy a file from one machine to another while
impersonating?

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to