title: Oracle Connection String With Windows Authentication
body: <p>We have a requirement to make our products work on Oracle as well as SQL Server (around which they were originally built). Unfortunately we don't have any in house Oracle development experience to speak of but as a senior dev it has fallen to me to lead the project. So far I have managed to make our app connect to an Oracle database (I'm using Oracle XE 11.2) by using the following connection string:</p>
  
  <pre><code>Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=VS010-ORA11GR1)(PORT=1523))(CONNECT_DATA=(SERVICE_NAME=DEVORA)));User Id=dbo;Password=dbo;
  </code></pre>
  
  <p>The reason we decided to use this type of connection string is because we do not want to rely on changing tnsnames.ora on every client machine. However, as you can see this specifies an Oracle user and associated password. We also need to provide the ability to use the equivalent of SQL Server integrated security.</p>
  
  <p>According to the literature I have read, to do this I simply need to specify <code>/</code> as the user id and then omit the password portion (as this is ignored anyway for Windows authentication). I also created the user in Oracle, making sure it matched the Windows user, with the following snippets:</p>
  
  <pre><code>CREATE USER "OPS$&lt;DOMAIN&gt;\&lt;user&gt;" IDENTIFIED EXTERNALLY;
  
  GRANT CONNECT,RESOURCE TO "OPS$&lt;DOMAIN&gt;\&lt;user&gt;";
  </code></pre>
  
  <p>I also checked that the sqlnet.ora file on my local machine which hosts the XE instance and my dev environment contained the line:</p>
  
  <pre><code>SQLNET.AUTHENTICATION_SERVICES= (NTS)
  </code></pre>
  
  <p>I understood that this would enable my app to connect to the Oracle database uing Windows Authentication. However what actually happens is that I get the following Oracle error message:</p>
  
  <blockquote>
    <p>ORA-01005: null password given; logon denied</p>
  </blockquote>
  
  <p>this doesn't make much sense because of course its null - it's supposed to be, according to the tutorials I've read. </p>
  
  <p>The app targets .Net Framework 3.5, we are using the System.Data.OracleProvider  and the actual connecting and so on is handled by Enterprise Library 5. Incidentally, I am aware of the deprecation of the OracleClient component but I just want this to work before I go into the extra complexities of changing providers.</p>
  
  <p>Can anyone tell me what I'm missing? Have I chosen the wrong type of connection string? I apologise for any basic mistakes but I have always managed to avoid Oracle until now so my knowledge of it is close to zero.</p>
  
  <p>Many thanks</p>