2

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>
2
  • Do you mean you are using LDAP to do Windows Authentication? Or am I misunderstanding your question. Have you tried "user id=/" and "password=" (no password, and forward slash for user id) Commented Jul 18, 2012 at 20:44
  • I didn't tried anything yet because I has to do this on acceptance env. which is already in use (application connects to SQL Server and Oracle and Oracle part of app is not working) and my time for experimenting is limited. Commented Jul 19, 2012 at 8:33

3 Answers 3

3

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>
Sign up to request clarification or add additional context in comments.

3 Comments

Does setting a username/password in the connection string affect LDAP? Or does it do LDAP then negate the username/password?
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.
U also need to have a sqlnet.ora file in the oraclehome folder/network/admin with the following contents.
0

If you use "/" for username and leave password blank, it will change to Windows Authentication.

Here is the MSDN article on Connecting to the Oracle Database Using Windows Authentication and this question addresses a problem where a user cannot connect to the Oracle database using ODP.NET and its fix.

Here's what one of my App.Config connection strings looks like to connect using Windows Authentication:

 <connectionStrings>
      <add name="EntityFrameworkEntities" connectionString="metadata=res://*/EntityFrameworkModel.csdl|res://*/EntityFrameworkModel.ssdl|res://*/EntityFrameworkModel.msl;provider=Oracle.DataAccess.Client;provider connection string=&quot;DATA SOURCE=EntityFrameworkDatabase;PASSWORD=;USER ID=/&quot;" providerName="System.Data.EntityClient"/>
 </connectionStrings>

1 Comment

I am not using Windows Authentication. It is some Unix or Oracle LDAP with lots of Oracle databases in it.
0

U also need to have a sqlnet.ora file in the oraclehome folder/network/admin with the following contents

# sqlnet.ora Network Configuration File

SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (LDAP,TNSNAMES,EZCONNECT)

and LDAP.ora with following contents

DEFAULT_ADMIN_CONTEXT = "dc=world"
DIRECTORY_SERVERS = (server1.x.com:389:636, server2.x.com:389:636)
DIRECTORY_SERVER_TYPE = OID

Ldap.ora help

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.