title: How can I connect to a database on another virtual machine through WCF?
body: <p>We've got a WCF service that used to connect to a database on the same machine. We have since moved both the database and the service to different machines (both virtual machines on the same physical box that can see one another).</p>
  
  <p>I've set up a standard windows login on the database machine (WCFServiceLogin), added a database login on the database pointing to that windows login, added a SQL user to the database that points to that database login, and changed the connection string in the Visual Studio project settings:</p>
  
  <pre><code>Data Source=NewServer;Initial Catalog=MyDB;Integrated Security=True;
  UserID=WCFServiceLogin;Password=password
  </code></pre>
  
  <p>When I try to make a call that touches the database, I get this error:</p>
  
  <blockquote>
    <p>Login failed for user 'NT
    AUTHORITY\ANONYMOUS LOGON'.</p>
  </blockquote>
  
  <p>How can I get my WCF operations to successfully read from a database on a new machine, using the correct login?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I think I've managed to get a little farther. I created a WCFServiceLogin login on the machine that the service is on with the same password as its counterpart on NewServer. I then set my WCF service to run as this login, and changed the SQL login to use Windows Authentication, and removed the User ID and Password from the connection string. Lastly, I ran exec sp_grantlogin 'NewServer\WCFServiceLogin'.</p>
  
  <p>I'm now getting this error, though:</p>
  
  <blockquote>
    <p>Cannot open database "MyDB" requested
    by the login. The login failed. Login
    failed for user
    'NewServer\WCFServiceLogin'.</p>
  </blockquote>
  
  <p>So it seems like it's trying to log in with the right user, it's just failing to do so. </p>