使用实体框架和 LDAP 的 Oracle 连接字符串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11544191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Connection string for Oracle using Entity Framework and LDAP
提问by Robert Vukovi?
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.
我有一个 ASP.NET 4.0 应用程序,它使用 Entity Framework 4.3 连接到 Oracle 数据库。在开发环境上连接不是问题,因为我们使用标准方法。连接字符串由 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.
问题是在生产和验收环境中,我们必须使用 LDAP。我已经验证了连接并且可以使用来自 Oracle 的 SQL Developer 的 LDAP 进行连接。
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.
我需要有关 web.config 中连接字符串语法的帮助。它应该是什么样子?我找不到任何示例,并且在生产和验收时,我没有 Visual Studio 来查看它是否可以自动生成某些内容。
Update:
I need syntax to change this connection string that is connecting to local Oracle Express to connection string that uses LDAP
更新:
我需要将连接到本地 Oracle Express 的连接字符串更改为使用 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="DATA SOURCE=localhost:1521;PASSWORD=somePassKey;PERSIST SECURITY INFO=True;USER ID=someUser"" providerName="System.Data.EntityClient" />
</connectionStrings>
回答by Robert Vukovi?
To answer if someone else needs it. Solution is relatively simple:
回答别人是否需要它。解决方法比较简单:
LDAP.ORA file has to be modified with correct LDAP Parameters
必须使用正确的 LDAP 参数修改 LDAP.ORA 文件
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
并且比连接字符串类似于没有 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="DATA SOURCE=sameDbName;PASSWORD=somePass;USER ID=someUser;"" providerName="System.Data.EntityClient" />
</connectionStrings>
回答by Bob.
If you use "/" for username and leave password blank, it will change to Windows Authentication.
如果您使用“/”作为用户名并将密码留空,它将更改为 Windows 身份验证。
Here is the MSDN article on Connecting to the Oracle Database Using Windows Authenticationand this questionaddresses a problem where a user cannot connect to the Oracle database using ODP.NET and its fix.
这是关于使用 Windows 身份验证连接到 Oracle 数据库的 MSDN 文章,该问题解决了用户无法使用 ODP.NET 连接到 Oracle 数据库及其修复的问题。
Here's what one of my App.Config connection strings looks like to connect using Windows Authentication:
这是我的 App.Config 连接字符串之一使用 Windows 身份验证连接的样子:
<connectionStrings>
<add name="EntityFrameworkEntities" connectionString="metadata=res://*/EntityFrameworkModel.csdl|res://*/EntityFrameworkModel.ssdl|res://*/EntityFrameworkModel.msl;provider=Oracle.DataAccess.Client;provider connection string="DATA SOURCE=EntityFrameworkDatabase;PASSWORD=;USER ID=/"" providerName="System.Data.EntityClient"/>
</connectionStrings>
回答by Sundara Prabu
U also need to have a sqlnet.ora file in the oraclehome folder/network/admin with the following contents
你还需要在oraclehome文件夹/network/admin下有一个sqlnet.ora文件,内容如下
# sqlnet.ora Network Configuration File
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (LDAP,TNSNAMES,EZCONNECT)
and LDAP.ora with following contents
和 LDAP.ora 具有以下内容
DEFAULT_ADMIN_CONTEXT = "dc=world"
DIRECTORY_SERVERS = (server1.x.com:389:636, server2.x.com:389:636)
DIRECTORY_SERVER_TYPE = OID