Home
Forums
New posts
Search forums
Articles
Latest reviews
Search resources
Members
Current visitors
Newsgroups
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Newsgroups
Microsoft DotNet
Microsoft C# .NET
remote impersonation issue
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Ulf, post: 5709015"] Hi all, I run into some problems when trying to copy a file to a remote machine. I first create with WMI a share on the remote machine (works fine), then impersonate with admin rights and try to copy the file using the File.Copy method. But the exception always returns a "(local)file not found" message. Could someone give me a hint where I make a mistake in the following code ? many thx in advance :) Ulf code : IntPtr tokenHandle = new IntPtr(0); tokenHandle = IntPtr.Zero; LogonUser(UserName, HostName, Password, 2, 0, ref tokenHandle); WindowsIdentity newId = new WindowsIdentity(tokenHandle); WindowsImpersonationContext newUser = newId.Impersonate(); try { File.Copy(filePath,"\\\\" + HostName + "\\" + shareName + "\\" + fileName,true); } catch(Exception copyEx) { MessageBox.Show("Copy failure\n" + copyEx.Message,HostName); } finally { newUser.Undo(); } [/QUOTE]
Verification
Post reply
Home
Forums
Newsgroups
Microsoft DotNet
Microsoft C# .NET
remote impersonation issue
Top