Advertisement
Guest User

Untitled

a guest
Apr 25th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Security.Principal;
  7. using System.IO;
  8.  
  9. namespace ConsoleApplication2
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. string username = @"Abservr.ivanov"; // Нужно чтобы соединялось и через домен и без.
  16. string password = @"Blab";
  17. string network_file_path = @"\172.10.0.80c$testtest.txt";
  18. string local_file_path = @"c:testtest.txt";
  19. AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
  20. WindowsIdentity idnt = new WindowsIdentity(username, password);
  21. WindowsImpersonationContext context = idnt.Impersonate();
  22. File.Copy(network_file_path, local_file_path, true);
  23. context.Undo();
  24. }
  25. }
  26. }
  27. `
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement