コード例 #1
0
ファイル: Extensions.cs プロジェクト: ThreeHeadz/Bam.Net
 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);
     }
 }
コード例 #2
0
ファイル: RunAs.cs プロジェクト: dekkerb115/Bam.Net
 public static void UndoImpersonate(RunAsContext contextWrapper)
 {
     if (contextWrapper != null &&
         contextWrapper.Context != null)
     {
         contextWrapper.Context.Undo();
     }
     if (contextWrapper.TokenHandle != IntPtr.Zero)
     {
         CloseHandle(contextWrapper.TokenHandle);
     }
 }