copy file over a network

  • Thread starter Thread starter Abubakar
  • Start date Start date
A

Abubakar

Hi,
I'm using pure win32 (no atl or mfc) to copy files from my pc to other pc.
Currently I'm administrator of the other person's pc so my copy of file is
successful without a problem by using following code:

BOOL ret =CopyFile(existingfilename,TEXT("\\\\pc5\\c$\\sample2.txt"),
FALSE );

This works fine. Now my concern is that if I'm not an admin of the other
guy's pc, it'll require username and password for my code to copying file.
In that case how will I specify the username and password? What apis are
used for that?

many thanks,

Ab.
 
Abubakar said:
BOOL ret =CopyFile(existingfilename,TEXT("\\\\pc5\\c$\\sample2.txt"),
FALSE );

This works fine. Now my concern is that if I'm not an admin of the other
guy's pc, it'll require username and password for my code to copying file.
In that case how will I specify the username and password? What apis are
used for that?

LogonUser(); // gets you a handle to a token

ImpersonateLoggedOnUser(); // "changes" security context

CopyFile(); // copies file under changed context

RevertToSelf(); // switches back to normal

Prior to XP you will need the SE_TCB_NAME ("act as part of the operating
system") privilege.

Regards,
Will
 
Thanks for reply. Its very helpful.

-Ab.


William DePalo said:
LogonUser(); // gets you a handle to a token

ImpersonateLoggedOnUser(); // "changes" security context

CopyFile(); // copies file under changed context

RevertToSelf(); // switches back to normal

Prior to XP you will need the SE_TCB_NAME ("act as part of the operating
system") privilege.

Regards,
Will
 
Back
Top