title: Authentication using SharePoint Web Services
body: <p>I am trying to call GetListItems from an asp.net app. </p>
  
  <pre><code>System.Net.NetworkCredential userDefined = new System.Net.NetworkCredential("username","password","domain");
  XmlDocument xmlDoc = new System.Xml.XmlDocument();
  XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
  XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
  XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
  ndQueryOptions.InnerXml = "";
  ndViewFields.InnerXml = "";
  
  WebReference.Lists lists = new WebReference.Lists();
  
  lists.Credentials = userDefined;
  XmlNode responseNode = lists.GetListItems("My List Name", null, ndQuery, ndViewFields, null, ndQueryOptions, null);
  </code></pre>
  
  <p>I am getting an error:</p>
  
  <pre><code>the request failed with http status 401 unauthorized
  </code></pre>
  
  <p>I have searched SO and tried what I have found:</p>
  
  <pre><code>WebReference.UseDefaultCredentials = true;
  </code></pre>
  
  <p>And</p>
  
  <pre><code>WebReference.Credentials = System.Net.CredentialCache.DefaultCredentials;
  </code></pre>
  
  <p>And</p>
  
  <pre><code>&lt;identity impersonate="true"  userName="mydomain\username" password="password" /&gt;
  </code></pre>
  
  <p>with everything I have tried I get the same error message. Would anyone know what I might be missing?</p>