title: pymssql windows authentication
body: <p>The pymssql module used to support windows authentication. Now it seems it does not. Though in some places it still shows that it should work. I have been unable to find a definitive answer to this problem, nor a solution. Most relevant link:</p>
  
  <p><a href="https://groups.google.com/forum/#!topic/pymssql/QDMLTGBNeU0" rel="noreferrer">https://groups.google.com/forum/#!topic/pymssql/QDMLTGBNeU0</a></p>
  
  <blockquote>
    <p>pymssql 1.0 supported it because it made use of and depended on the 
    MS-provided DLL which was part of the SQL Server client stack. This 
    stack was in charge of handling all of the NTLM negotiation and such. 
    This meant, among other things that it was a Windows-only solution. </p>
  </blockquote>
  
  <p>I can simulate many sorts of network environments so I have tried many different setups. I am trying to be able to use this script to connect to a remote MSSQL server using windows authentication. And this is the problem.</p>
  
  <hr>
  
  <p>According to my research, including the links above, there are two ways to use windows authentication with the pymssql module that are <em>supposed</em> to work.</p>
  
  <p><strong>First Method:</strong> Using the current users credentials:</p>
  
  <pre><code>pymssql.connect(server='server') 
  # credentials come from active windows session
  # some research shows that a "trusted=True" keyword should be provided.
  </code></pre>
  
  <p><strong>Second Method:</strong> Using a given users credentials:</p>
  
  <pre><code>pymssql.connect(server='server', user=r'domain\user', password='pass') 
  # credentials are given in code and somehow converted to a 
  # windows authentication in the background
  # some research shows that a "trusted=True" keyword should be provided.
  </code></pre>
  
  <p>The same goes for using the <code>_mssql</code> module.</p>
  
  <hr>
  
  <p><strong>NOTES:</strong> </p>
  
  <ul>
  <li>Python version: 2.7.8 </li>
  <li>Version of pymssql I am using: 2.1.1 </li>
  <li>Version of pymssql that used to support windows authentication: 1.x </li>
  <li>I have tested with (All 64 bit): 
  
  <ul>
  <li>windows 7 professional</li>
  <li>windows 7 home premium</li>
  <li>windows server 2012</li>
  <li>windows server 2012R2</li>
  </ul></li>
  </ul>
  
  <hr>
  
  <p>Other questions on the topic:</p>
  
  <p><a href="https://stackoverflow.com/questions/21313196/pymssql-how-to-use-windows-authentication-when-running-on-a-non-windows-box">pymssql: How to use windows authentication when running on a non-windows box</a></p>
  
  <p><a href="https://stackoverflow.com/questions/16885673/unable-to-connect-using-pymssql-with-windows-authentication">Unable to connect using pymssql with windows authentication</a></p>
  
  <p><a href="https://stackoverflow.com/questions/27692366/mssql-python-windows-authentication">https://stackoverflow.com/questions/27692366/mssql-python-windows-authentication</a></p>