title: Error "The username is not provided. Specify username in ClientCredentials." when passing CredentialCache.DefaultNetworkCredentials
body: <p>I am writing a simple C# console application that will make a call to the "Lists.asmx" web service on a SharePoint site in order to pull down attachments.  I've already added the service reference and tried to run it but it fails with the error </p>
  
  <blockquote>
    <p>The username is not provided. Specify username in ClientCredentials.</p>
  </blockquote>
  
  <p>when it tries to make a service method call to <code>GetAttachmentCollection</code>. Below is the code:</p>
  
  <pre><code>static void Main(string[] args)
  {
    ListsSoapClient client = new ListsSoapClient();
    client.ClientCredentials.Windows.ClientCredential = 
      CredentialCache.DefaultNetworkCredentials;
    XElement attachments = client.GetAttachmentCollection("Projects", "42");
  
    // Do something with the attachments
  }
  </code></pre>
  
  <p>As you can see I'm trying to set the <code>ClientCredential</code> to be the credentials for the the current user but it does not appear to be sending the user name.  My SharePoint site is configured with https and Windows Authentication.  Below is my simple config file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;startup&gt;
      &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /&gt;
    &lt;/startup&gt;
    &lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;basicHttpsBinding&gt;
          &lt;binding name="ListsSoap"&gt;
            &lt;security mode="TransportWithMessageCredential"&gt;
              &lt;transport clientCredentialType="Ntlm" 
                proxyCredentialType="None" realm=""/&gt;
              &lt;message clientCredentialType="UserName" algorithmSuite="Default"/&gt;
            &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/basicHttpsBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
        &lt;endpoint address="https://intranet.test.com/_vti_bin/Lists.asmx"
            binding="basicHttpsBinding" bindingConfiguration="ListsSoap"
            contract="ListServiceProxy.ListsSoap" name="ListsSoap" /&gt;
      &lt;/client&gt;
    &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I have tried <code>clientCredentialType="NtlM"</code> and <code>clientCredentialType="Windows"</code> but I get the same result.  Is there something wrong with my configuration file or some variable that I need to set on <code>client</code>?  </p>