Thus, there is no trust between the two machines - they are in different domains.
I successfully connected to the remote computer using the LogonUser API using the login type, LOGON32_LOGON_NEW_CREDENTIALS. I can get the contents of the directory using the UNC share and create a file stream to βdownloadβ the file. So far so good.
The only problem is that it seems that LogonUser fails if there is no session already open. Let me clarify this.
I found that the ASP.NET MVC page did not work today, namely the page that retrieves the list of files from this remote machine using LogonUser. I look at the log and I see in stacktrace, System.IO .__ Error.WinIOError over a call to Directory.GetFiles. Then I deleted to the web server and tried to open the remote folder in Explorer using the same username / password that is used on the website. He passed, and I saw the files. I opened a command prompt, typed net use, and I see that there is an open connection to the remote machine. Then I returned to the page and the page works again.
So, at the moment I'm not quite sure if LogonUser is working as expected or not. If a call requires the network connection to be opened first in other ways, this is certainly not satisfactory.
Does anyone know what might happen or suggest a workaround?
winapi impersonation
Jiho han
source share