Beispiel #1
0
 public static void CopyTo(this FileInfo file, string computerName, string userName, string password, string remotePath = null)
 {
     using (RunAsContext runasContext = RunAs.Impersonate(userName, password))
     {
         CopyTo(file, computerName, remotePath);
     }
 }
Beispiel #2
0
 public static void UndoImpersonate(RunAsContext contextWrapper)
 {
     if (contextWrapper != null &&
         contextWrapper.Context != null)
     {
         contextWrapper.Context.Undo();
     }
     if (contextWrapper.TokenHandle != IntPtr.Zero)
     {
         CloseHandle(contextWrapper.TokenHandle);
     }
 }