| Код | using System.Runtime.InteropServices; using System.Security.Principal; using System.Security.Permissions;
class Test { [DllImport("advapi32.dll", SetLastError = true)] public static extern bool LogonUser( string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, out IntPtr phToken ); public Test() { IntPtr adminToken; if (LogonUser("remote admin name","remote comp domain/group","pass", 9, 0, out adminToken)) { WindowsIdentity wi_remote = new WindowsIdentity(adminToken); WindowsImpersonationContext wic = wi_remote.Impersonate(); System.IO.File.Copy("local path", "remote path", true); } } }
|
|