title: WCF Proxy and userPrincipalName
body: <p>We have a rather large application my team and I are developing that contains a number of WCF NetTCP-based services. The Windows service this system will be running under won't be a local account, but instead a standard domain user (with admin privileges on the servers hosting the service). In the middle of testing connectivity I ran into an issue where SSPI calls fail. Based on a few hours of research this has led me down the path of me missing the following line from my client config:</p>
  
  <pre><code>&lt;identity&gt;
       &lt;userPrincipalName value="MACHINE\user" /&gt;
  &lt;/identity&gt;
  </code></pre>
  
  <p>The problem with using this is I don't use VS or svcutil to generate a client/proxy for this service - the proxies being used are completely written in code and they inherit System.ServiceModel.ClientBase. I believe the original reason this option was chosen was so we could use the exact same DataMember objects that pass through the services on either side of the fence - third party groups won't need to connect to our services so this wasn't a problem.</p>
  
  <p>Does anyone know a way for me to set userPrincipalName in the client (code or through a config) when I don't have endpoints specified in the standard system.serviceModel configuration section?</p>
  
  <p>Here's what my client-side web.config looks like for reference:</p>
  
  <pre><code>    &lt;system.serviceModel&gt;
      &lt;diagnostics&gt;
          &lt;messageLogging logEntireMessage="true" logMalformedMessages="true"
           logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" /&gt;
      &lt;/diagnostics&gt;
      &lt;behaviors&gt;
          &lt;serviceBehaviors&gt;
              &lt;behavior name="includeExceptions"&gt;
                  &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
                  &lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt;
              &lt;/behavior&gt;
          &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;bindings&gt;
          &lt;netTcpBinding&gt;
              &lt;binding name="NetTcpBinding_Default" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="Infinite" sendTimeout="01:00:00" portSharingEnabled="true" transferMode="Buffered" maxReceivedMessageSize="2147483647"&gt;
                  &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt;
                  &lt;security mode="Transport"&gt;
                      &lt;transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/&gt;
                  &lt;/security&gt;
              &lt;/binding&gt;
          &lt;/netTcpBinding&gt;
      &lt;/bindings&gt;
  
  &lt;/system.serviceModel&gt;
  </code></pre>