Connection string for Oracle using Entity Framework and LDAP

11,412

To answer if someone else needs it. Solution is relatively simple:

LDAP.ORA file has to be modified with correct LDAP Parameters

DIRECTORY_SERVERS=(tnsnames.somesite.org:389:636)
DEFAULT_ADMIN_CONTEXT="dc=site,dc=com"
DIRECTORY_SERVER_TYPE=OID

and than the connection string is similar to the situation without the LDAP

 <connectionStrings>
    <add name="VoccDbContext" connectionString="metadata=res://*/Entities.Vocc.VoccModel.csdl|res://*/Entities.Vocc.VoccModel.ssdl|&#xD;&#xA;        res://*/Entities.Vocc.VoccModel.msl;provider=Oracle.DataAccess.Client;provider connection string=&quot;DATA SOURCE=sameDbName;PASSWORD=somePass;USER ID=someUser;&quot;"         providerName="System.Data.EntityClient" />
</connectionStrings>
Share:
11,412
Robert Vuković
Author by

Robert Vuković

LinkedIn

Updated on June 04, 2022

Comments

  • Robert Vuković
    Robert Vuković almost 2 years

    I have an ASP.NET 4.0 application that is using Entity Framework 4.3 to connect to Oracle database. Connection on a development environment is not a problem because we use the standard method. Connection string was generated by Visual Studio.

    Problem is that on production and acceptance environments we have to use LDAP. I have verified connection and can connect using the LDAP from Oracle's SQL Developer.

    I need a help with the syntax of connection string in the web.config. How it should look like? I was not be able to find any examples and on production and acceptance I don't have Visual Studio to see if it can generate something automatically.

    Update:
    I need syntax to change this connection string that is connecting to local Oracle Express to connection string that uses LDAP

    <connectionStrings>
        <add name="VoccDbContext" connectionString="metadata=res://*/Entities.Vocc.VoccModel.csdl|res://*/Entities.Vocc.VoccModel.ssdl|res://*/Entities.Vocc.VoccModel.msl;provider=Oracle.DataAccess.Client;provider connection string=&quot;DATA SOURCE=localhost:1521;PASSWORD=somePassKey;PERSIST SECURITY INFO=True;USER ID=someUser&quot;" providerName="System.Data.EntityClient" />
    </connectionStrings>
    
  • Robert Vuković
    Robert Vuković over 11 years
    I am not using Windows Authentication. It is some Unix or Oracle LDAP with lots of Oracle databases in it.
  • Bob.
    Bob. over 11 years
    Does setting a username/password in the connection string affect LDAP? Or does it do LDAP then negate the username/password?
  • Robert Vuković
    Robert Vuković over 11 years
    Because I am connecting to multiple databases test,acc,prod for each I use different password so by my understanding LDAP only maps database name to specific machine/Oracle instance so it is possible to change Oracle machines without the need to update client connection strings.
  • Sundara Prabu
    Sundara Prabu over 9 years
    U also need to have a sqlnet.ora file in the oraclehome folder/network/admin with the following contents.