Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>While I don't know myself, I would certainly hope that #2 is incorrect...I'd like to think that Windows isn't going to AUTOMATICALLY give out my login information (least of all my password!) to any machine, let alone one that isn't part of my trust.</p> <p>Regardless, have you explored the impersonation architecture? Your code is going to look similar to this:</p> <pre><code>using (System.Security.Principal.WindowsImpersonationContext context = System.Security.Principal.WindowsIdentity.Impersonate(token)) { // Do network operations here context.Undo(); } </code></pre> <p>In this case, the <code>token</code> variable is an IntPtr. In order to get a value for this variable, you'll have to call the unmanaged LogonUser Windows API function. A quick trip to <a href="http://pinvoke.net/default.aspx/advapi32.LogonUser" rel="nofollow noreferrer">pinvoke.net</a> gives us the following signature:</p> <pre><code>[System.Runtime.InteropServices.DllImport("advapi32.dll", SetLastError = true)] public static extern bool LogonUser( string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, out IntPtr phToken ); </code></pre> <p>Username, domain, and password should seem fairly obvious. Have a look at the various values that can be passed to dwLogonType and dwLogonProvider to determine the one that best suits your needs.</p> <p>This code hasn't been tested, as I don't have a second domain here where I can verify, but this should hopefully put you on the right track.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload