具有Windows身份验证的Oracle连接字符串 [英] Oracle Connection String With Windows Authentication

查看:127
本文介绍了具有Windows身份验证的Oracle连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要使我们的产品能够在Oracle以及SQL Server(最初围绕它们构建)上运行.不幸的是,我们没有任何内部Oracle开发经验可言,但是作为高级开发人员,我要领导这个项目.到目前为止,我已经通过使用以下连接字符串使我们的应用程序连接到Oracle数据库(我正在使用Oracle XE 11.2):

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:

Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=VS010-ORA11GR1)(PORT=1523))(CONNECT_DATA=(SERVICE_NAME=DEVORA)));User Id=dbo;Password=dbo;

之所以决定使用这种类型的连接字符串,是因为我们不想依赖于在每台客户端计算机上更改tnsnames.ora.但是,如您所见,这指定了Oracle用户和关联的密码.我们还需要提供使用等效的SQL Server集成安全性的功能.

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.

根据我阅读的文献,要做到这一点,我只需要指定/作为用户ID,然后省略密码部分(因为Windows身份验证始终忽略此部分).我还使用以下代码段在Oracle中创建了用户,以确保它与Windows用户匹配:

According to the literature I have read, to do this I simply need to specify / 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:

CREATE USER "OPS$<DOMAIN>\<user>" IDENTIFIED EXTERNALLY;

GRANT CONNECT,RESOURCE TO "OPS$<DOMAIN>\<user>";

我还检查了托管XE实例和开发环境的本地计算机上的sqlnet.ora文件是否包含以下行:

I also checked that the sqlnet.ora file on my local machine which hosts the XE instance and my dev environment contained the line:

SQLNET.AUTHENTICATION_SERVICES= (NTS)

我知道这将使我的应用程序能够使用Windows身份验证连接到Oracle数据库.但是,实际发生的是我收到以下Oracle错误消息:

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:

ORA-01005:提供了空密码;登录被拒绝

ORA-01005: null password given; logon denied

这当然没有意义,因为它为null-根据我阅读的教程,应该为null.

this doesn't make much sense because of course its null - it's supposed to be, according to the tutorials I've read.

该应用程序针对.Net Framework 3.5,我们使用的是System.Data.OracleProvider,实际的连接等由企业库5处理.顺便说一句,我知道OracleClient组件已弃用,但我只想在我研究更改提供者的额外复杂性之前,这种方法是可行的.

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.

谁能告诉我我想念的东西吗?我选择了错误的连接字符串类型吗?对于任何基本错误,我深表歉意,但直到现在我一直设法避免使用Oracle,因此我对此的了解几乎为零.

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.

非常感谢

推荐答案

使用@Stikut扩展上述答案.我使用NHibernate 3.3.3.GA进行了测试,并且可以正常工作.

To expand on the answer above by @Stikut. I tested this out with NHibernate 3.3.3.GA and it works.

user id=/;password=;Integrated Security=yes

这篇关于具有Windows身份验证的Oracle连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆