title: How to connect Python's pyodbc to MS SQL using AD Universal Authentication?
body: <p>I'm connecting to two databases the first one uses 'SQL Server Authentication' the second which is the issue uses 'Active Directory Universal Authentication'.</p>
  
  <p>Running this on Win 7, python 2.7.12, pyodbc v4.0.17, Microsoft Online Services Sign-in Assistant is installed and I normally access the database from MSSMS 2016.</p>
  
  <p>For the first database I use the following, which works:</p>
  
  <pre><code>cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=ourDatabase.database.windows.net;PORT=1433;DATABASE=ourDataBaseName;UID=USERID;PWD=PASSWORD')
  </code></pre>
  
  <p>The second database I've tried all of these, which don't work:</p>
  
  <pre><code>cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=.\ourDatabase.database.windows.net;DATABASE=ourDataBaseName;UID=user@companydomain.com;PWD=MyPass;Trusted_Connection=yes')
  
  cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=ourDatabase.database.windows.net;DATABASE=ourDataBaseName;UID=user@companydomain.com;PWD=MyPass;Trusted_Connection=yes')
  
  cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=ourDatabase.database.windows.net;DATABASE=ourDataBaseName;UID=user;PWD=MyPass;Trusted_Connection=yes')
  
  cnxn = pyodbc.connect('DRIVER={ODBC Driver 13 for SQL Server};SERVER=.\ourDatabase.database.windows.net;DATABASE=ourDataBaseName;UID=user@companydomain.com;PWD=MyPass;Trusted_Connection=yes')
  </code></pre>
  
  <p>What am I missing here?</p>