title: Impersonation failing for database connection
body: <p>I have a SL4 app that uses WCF to communicate with a backend SQL Server 2008 database.  One of the WCF services needs to connect to the database with a dedicated system account due to the database permissions required by the stored procedure that is called.  I have attempted to implement a solution using impersonation within the service code e.g.</p>
  
  <pre><code>int result = LogonUser(userName, domain, password,
      LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, out _token);
  
  if (result &gt; 0)
  {
      ImpersonateLoggedOnUser(_token);
      //Code here to call NHibernate data access code
  }
  </code></pre>
  
  <p>My connection string for this service is:</p>
  
  <pre><code>&lt;add name="MyConnection" connectionString="Data Source=servername\instance;Initial Catalog=MyDatabase;Integrated Security=SSPI" providerName="System.Data.SqlClient"/&gt;
  </code></pre>
  
  <p>However, the data access routine is still failing with the following message:</p>
  
  <blockquote>
    <p>Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.</p>
  </blockquote>
  
  <p>The impersonation is being ignored in the database connection. Any ideas?</p>