title: How to add windows user as a SQL users in windows authentication mode
body: <p>I want to add windows user to SQL users pragmatically. my problem is that I want to do this on systems that have SQL installed in mixed mode but I don't have username and password , I just know the instance name and I don't know how can I execute my script of adding windows user to SQL users in this situation.</p>
  
  <p>I know the script is :</p>
  
  <pre><code>use master
  GO
  
  create login [&lt;YourDomain&gt;\User1] from windows;
  GO
  </code></pre>
  
  <p>my connection string is :</p>
  
  <pre><code>ServerConnection myServerConnection = new ServerConnection(myinstancename);
  Server myServer = new Server(myServerConnection);
  
  SqlConnection scSqlConnction = new SqlConnection(myServerConnection.ConnectionString);
  </code></pre>
  
  <p>but when I create a server connection with my instance name, and want to execute script with related connection string I get the error of </p>
  
  <blockquote>
    <p>login failed for user (windows user)</p>
  </blockquote>