Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Security.Principal;
- using System.IO;
- namespace ConsoleApplication2
- {
- class Program
- {
- static void Main(string[] args)
- {
- string username = @"Abservr.ivanov"; // Нужно чтобы соединялось и через домен и без.
- string password = @"Blab";
- string network_file_path = @"\172.10.0.80c$testtest.txt";
- string local_file_path = @"c:testtest.txt";
- AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
- WindowsIdentity idnt = new WindowsIdentity(username, password);
- WindowsImpersonationContext context = idnt.Impersonate();
- File.Copy(network_file_path, local_file_path, true);
- context.Undo();
- }
- }
- }
- `
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement