title: How do I supply credentials to execute a query on a server that's part of another domain?
body: <p>I am doing work for a client that has a server on his domain.  My workstation is on my own domain.  I typically VPN into the client network using my client domain username and password.  The problem with the below query is that I get a 401 Unauthorized access error when I execute the query, presumably because the wrong credentials are being sent.</p>
  
  <p>The client has suggested supplying my client domain credentials, perhaps wrapped in a #if DEBUG so that the code will work properly in development environments.</p>
  
  <p>How do I supply credentials?  The following code will be present in an ASP MVC 2 project.</p>
  
  <pre><code>        ClientContext clientContext = new ClientContext(URL);
          List list = clientContext.Web.Lists.GetByTitle("My Documents");
  
          CamlQuery camlQuery = new CamlQuery();
          camlQuery.ViewXml = XML;
          ListItemCollection listItems = list.GetItems(camlQuery);
          clientContext.Load(
               listItems,
               items =&gt; items.Include(item =&gt; item["FileRef"]));
  
          clientContext.ExecuteQuery();
  </code></pre>
  
  <p>I prefer to do this programatically</p>