Access remote PC's share file by UNC path with username/password

Trips

Well-known member
Joined
Aug 7, 2010
Messages
2,788
I need to read some xml file in the remote PCs share folder by XmlReader of C#.<br/>But the share folder have username and password.<br/>what can I do?<br/>pass the remote PCs username and password with the UNC for authenticate.<br/><br/>I have tryed the Win32API LogonUser with WindowsImpersonationContext of C#, but faild.<br/>[DllImport("advapi32.dll", SetLastError = true)]<br/> public static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword,<br/> int dwLogonType, int dwLogonProvider, ref IntPtr phToken);<br/>I set the parameter of LogonUser like this.<br/><br/>lpszUsername = Remote PCs username, like "guest"<br/>lpszDomain = Remote PCs IP or HostName, like "172.25.73.116" or "Client2"<br/>lpszPassword = the password of Remote PCs username<br/><br/>Is there Someone can tell me why access faild and how can I implement the request.<br/>Thsnks a lots of.

View the full article
 
Back
Top