现在的位置: 首页 > 综合 > 正文

Net Web应用无法连接Oracle

2013年08月07日 ⁄ 综合 ⁄ 共 10932字 ⁄ 字号 评论关闭
Net Web应用无法连接Oracle

关于.Net 应用无法连接Oracle数据库,从来不是什么新问题,而是一个经常困扰程序部署人员的痼疾,从遥远的过去到现在,它时不时地就蹦出来,烦你一阵。

该问题的具体症状是数据库连接字符串的udl试验没问题,plsql developer 没问题, Sql/Plus 没问题,可是.Net应用却总报无法连接Oracle数据库的错:调用的目标发生了异常!

好在有前人的的努力,解决这个无厘头的问题也不再是多么困难的事情。一位老大早在03年就搞定了这个问题,虽然搞定的过程也异常郁闷。以下摘自该君的邮件。

-------------------------------------------
发件人: gene
发送时间: 2003年8月21日 10:15
主题: 莫名其妙的一夜
………………………... 由于公司网络问题研发许多主机没在线,只好下载了oracle client9.2.0.1,结果此版本在IIS下的backend不能连接数据库,但sms service确可正常连接,……………………….后查阅资料发现此为oracle一个bug,原因是NTFS的安全与IIS运行的用户模式问题,解决方法如下,以共借鉴:

到Oracle/ora92 打开Ora92的-》属性-》安全,选Authenticated Users 看下面的属性 将Read and Execute 的勾去掉,然后又勾上,确定重新启动机器 ,ok 搞定,就是这么简单,当然要避免这种问题,您可以这么做:不要安装Oracle9.2 或者不要安装在NTFS格式的分区。

附上
Oracle 公司的原版资料:
Problem Description ------------------- When running an application that connects to Oracle and uses the Authenticated User privilege (such as Microsoft's Internet Information Server (IIS)) via Oracle's 9.2 client software and any of these programmatic interfaces
1. Oracle Provider for OLE DB 2. Microsoft OLE DB Provider for Oracle 3. Oracle ODBC Driver 4. Microsoft ODBC for Oracle 5. Oracle Objects for OLE (OO4O) you will receive one of the following errors: (1) Oracle Provider for OLE DB Error Type: Microsoft OLE
DB Service Components (0x80070005) Access is denied. (2) Microsoft OLE DB Provider for Oracle Error Type: Microsoft OLE DB Provider for Oracle (0x80004005) Oracle client and networking components were not found. These components are supplied by Oracle Corporation
and are part of the Oracle Version 7.3.3 or later client software installation. Provider is unable to function until these components are installed. Or Error Type: Microsoft OLE DB Provider for Oracle (0x80004005) Oracle error occurred, but error message could
not be retrieved from Oracle. (3) Oracle ODBC Driver Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) Specified driver could not be loaded due to system error 5 (Oracle in OraHome92). (4) Microsoft ODBC for Oracle The Oracle(tm) client and
networking components were not found. These components are supplied by Oracle Corporation and are part of the Oracle Version 7.3 (or greater) client software installation. You will be unable to use this driver until these components have been installed. (5)
Oracle Objects for OLE (a) while using a GLOBAL.ASA file Error Type: Active Server Pages (0x0) An error occurred while creating object 'OraSession'. (b) not using a GLOBAL.ASA file Error Type: Microsoft VBScript runtime (0x800A0046) Permission denied: 'CreateObject'
(6) Other miscellaneous errors (a) The Specified Module Could Not Be Found Solution Description -------------------- You need to give the Authenticated User privilege to the Oracle Home by following these steps: 1. Log on to Windows as a user with Administrator
privileges. 2. Launch Windows Explorer from the Start Menu and and navigate to the ORACLE_HOME directory. 3. Right-click on the ORACLE_HOME folder and choose the "Properties" option from the drop down list. A "Properties" window should appear. 4. Click on
the "Security" tab on the "Properties" window. 5. Click on "Authenticated Users" item in the "Name" list (on Windows XP the "Name" list is called "Group or user names"). 6. Uncheck the "Read and Execute" box in the "Permissions" list (on Windows XP the "Permissions"
list is called "Permissions for Authenticated Users"). This box will be under the "Allow" column. 7. Check the "Read and Execute" box. This is the box you just unchecked. 8. Click the "Apply" button. 9. Click the "OK" button. 10. You may need to reboot your
computer after these changes have been made. Re-execute the application and it should now work. Explanation ----------- If you install Oracle9i Release 2 (9.2.0.1) on a computer running Windows with an NTFS partition, the contents of ORACLE_HOME directory
will not be visible to users who are authenticated on that machine. These permissions were not set properly when the software was installed. Applications that were working fine with previous versions of Oracle software will stop working when they upgrade to
Oracle 9.2. NOTE: The application will continue to work if the user has logged onto the machine as an Administrator. Any application that is using the Authenticated User privilege will not work. A notable example would be IIS which might service some of the
requests based on the Authenticated User privileges. To demonstrate the problem in further detail, you can log on to the operating system as an authenticated machine user. You won't be able browse the contents of the ORACLE_HOME directory demonstrating your
inability to load any Oracle DLLs or make a connection. References ---------- Bug:2498880 - Oracle 9I Release 2 Installation Issue on Windows 2000 NTFS File System Additional Search Words ----------------------- OLEDB

整个安装过程一直处于苦思冥想的郁闷状态!
---------------------------------------------------------------------------

时值今天 ,我们也不得不感谢gene 的那晚苦思冥想的郁闷,正是他一夜的郁闷让我们以后解决这类没头绪的问题变得异常轻松。

我们的.Net应用绝大多数都是部署在ntfs分区,我们的数据库客户端也大多是Oracle9.2 ,所以这样的问题就屡见不鲜。按照邮件介绍的操作,大多数情况都能解决问题。如果还不行,把用户Aspnet和Internet 来宾用户IUSR_COMPUTERNAME加入Ora92的安全权限里,无法连接的问题就可以解决。从来就是这么简单,一直到上周五。

上周五某平台测试机部署时同样遇见这个问题,操作系统windows 2003,Oracle客户端9201。用户Aspnet和Interet 来宾用户IUSR_COMPUTERNAME 已经加入Ora92的安全权限里,不行。匿名访问用户赋予管理员权限,还不行。检查system.config,web.config,没发现任何异常。替换oracle本身提供的provider也不行。重启IIS,重启3w服务,重启机器,怎么折腾都不行。真是郁闷古今同啊。最后,已经准备做换机器这样无奈的打算了。还好,在绝望之前又仔细检查了一些细节。

windows 2000和2003的ASP.NET 的体系结构其实是有结构上的差异的。在 Windows 2000 上,多个 Web 应用程序运行于 ASP.NET 工作进程 (Aspnet_wp.exe) 的单个实例中。每个应用程序驻留在其自己的应用程序域中,该域为托管节点提供一定程度的隔离。而在 Windows Server 2003 上,体系结构发生更改,因为 IIS 6 允许使用多个进程来驻留独立的 Web 应用程序。与 Windows 2000 下的 ASP.NET 体系结构相比,Windows Server
2003 中的ASP.NET 体系结构的主要区别在于可以使用单独的 IIS 工作进程实例 (W3wp.exe) 来驻留 Web 应用程序。默认情况下,所有的应用程序都在默认应用程序池中运行。

所以,对默认的应用程序池的配置又做了最后一次详细的检查,在默认的应用程序池属性中标识页,发现有一个预定义帐户选项,列出了三个选项:网络服务 (NetworkService)、本地系统 (LocalSystem)、本地服务 (LocalService) 。当前选中的网络服务,而该帐户是这三个帐户权限最低的,将选项改为本地系统,重启IIS,久违的输入框出现了,终于正常连接到数据库。

小结:如果问题确认出现在环境上,那么就仔细检查每一个细节,以及每一个可能相关的配置项。

 总结:解决方案:第一步,在oracle安装目录(d:/oracle/ora92)上右键,属性->安全,选中Authenticated Users将权限的读取和运行项的勾去掉再打上,然后点击应用,再点击高级确定该用户应用于该文件夹,子文件夹及文件;第二步在ISS中相应项目的应用程序池上右键属性,点标识标签,在预定义帐户项选本地系统,然后重启ISS,OK,登录正常。

Net Web应用无法连接Oracle

关于.Net 应用无法连接Oracle数据库,从来不是什么新问题,而是一个经常困扰程序部署人员的痼疾,从遥远的过去到现在,它时不时地就蹦出来,烦你一阵。

该问题的具体症状是数据库连接字符串的udl试验没问题,plsql developer 没问题, Sql/Plus 没问题,可是.Net应用却总报无法连接Oracle数据库的错:调用的目标发生了异常!

好在有前人的的努力,解决这个无厘头的问题也不再是多么困难的事情。一位老大早在03年就搞定了这个问题,虽然搞定的过程也异常郁闷。以下摘自该君的邮件。

-------------------------------------------
发件人: gene
发送时间: 2003年8月21日 10:15
主题: 莫名其妙的一夜
………………………... 由于公司网络问题研发许多主机没在线,只好下载了oracle client9.2.0.1,结果此版本在IIS下的backend不能连接数据库,但sms service确可正常连接,……………………….后查阅资料发现此为oracle一个bug,原因是NTFS的安全与IIS运行的用户模式问题,解决方法如下,以共借鉴:

到Oracle/ora92 打开Ora92的-》属性-》安全,选Authenticated Users 看下面的属性 将Read and Execute 的勾去掉,然后又勾上,确定重新启动机器 ,ok 搞定,就是这么简单,当然要避免这种问题,您可以这么做:不要安装Oracle9.2 或者不要安装在NTFS格式的分区。

附上
Oracle 公司的原版资料:
Problem Description ------------------- When running an application that connects to Oracle and uses the Authenticated User privilege (such as Microsoft's Internet Information Server (IIS)) via Oracle's 9.2 client software and any of these programmatic interfaces
1. Oracle Provider for OLE DB 2. Microsoft OLE DB Provider for Oracle 3. Oracle ODBC Driver 4. Microsoft ODBC for Oracle 5. Oracle Objects for OLE (OO4O) you will receive one of the following errors: (1) Oracle Provider for OLE DB Error Type: Microsoft OLE
DB Service Components (0x80070005) Access is denied. (2) Microsoft OLE DB Provider for Oracle Error Type: Microsoft OLE DB Provider for Oracle (0x80004005) Oracle client and networking components were not found. These components are supplied by Oracle Corporation
and are part of the Oracle Version 7.3.3 or later client software installation. Provider is unable to function until these components are installed. Or Error Type: Microsoft OLE DB Provider for Oracle (0x80004005) Oracle error occurred, but error message could
not be retrieved from Oracle. (3) Oracle ODBC Driver Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) Specified driver could not be loaded due to system error 5 (Oracle in OraHome92). (4) Microsoft ODBC for Oracle The Oracle(tm) client and
networking components were not found. These components are supplied by Oracle Corporation and are part of the Oracle Version 7.3 (or greater) client software installation. You will be unable to use this driver until these components have been installed. (5)
Oracle Objects for OLE (a) while using a GLOBAL.ASA file Error Type: Active Server Pages (0x0) An error occurred while creating object 'OraSession'. (b) not using a GLOBAL.ASA file Error Type: Microsoft VBScript runtime (0x800A0046) Permission denied: 'CreateObject'
(6) Other miscellaneous errors (a) The Specified Module Could Not Be Found Solution Description -------------------- You need to give the Authenticated User privilege to the Oracle Home by following these steps: 1. Log on to Windows as a user with Administrator
privileges. 2. Launch Windows Explorer from the Start Menu and and navigate to the ORACLE_HOME directory. 3. Right-click on the ORACLE_HOME folder and choose the "Properties" option from the drop down list. A "Properties" window should appear. 4. Click on
the "Security" tab on the "Properties" window. 5. Click on "Authenticated Users" item in the "Name" list (on Windows XP the "Name" list is called "Group or user names"). 6. Uncheck the "Read and Execute" box in the "Permissions" list (on Windows XP the "Permissions"
list is called "Permissions for Authenticated Users"). This box will be under the "Allow" column. 7. Check the "Read and Execute" box. This is the box you just unchecked. 8. Click the "Apply" button. 9. Click the "OK" button. 10. You may need to reboot your
computer after these changes have been made. Re-execute the application and it should now work. Explanation ----------- If you install Oracle9i Release 2 (9.2.0.1) on a computer running Windows with an NTFS partition, the contents of ORACLE_HOME directory
will not be visible to users who are authenticated on that machine. These permissions were not set properly when the software was installed. Applications that were working fine with previous versions of Oracle software will stop working when they upgrade to
Oracle 9.2. NOTE: The application will continue to work if the user has logged onto the machine as an Administrator. Any application that is using the Authenticated User privilege will not work. A notable example would be IIS which might service some of the
requests based on the Authenticated User privileges. To demonstrate the problem in further detail, you can log on to the operating system as an authenticated machine user. You won't be able browse the contents of the ORACLE_HOME directory demonstrating your
inability to load any Oracle DLLs or make a connection. References ---------- Bug:2498880 - Oracle 9I Release 2 Installation Issue on Windows 2000 NTFS File System Additional Search Words ----------------------- OLEDB

整个安装过程一直处于苦思冥想的郁闷状态!
---------------------------------------------------------------------------

时值今天 ,我们也不得不感谢gene 的那晚苦思冥想的郁闷,正是他一夜的郁闷让我们以后解决这类没头绪的问题变得异常轻松。

我们的.Net应用绝大多数都是部署在ntfs分区,我们的数据库客户端也大多是Oracle9.2 ,所以这样的问题就屡见不鲜。按照邮件介绍的操作,大多数情况都能解决问题。如果还不行,把用户Aspnet和Internet 来宾用户IUSR_COMPUTERNAME加入Ora92的安全权限里,无法连接的问题就可以解决。从来就是这么简单,一直到上周五。

上周五某平台测试机部署时同样遇见这个问题,操作系统windows 2003,Oracle客户端9201。用户Aspnet和Interet 来宾用户IUSR_COMPUTERNAME 已经加入Ora92的安全权限里,不行。匿名访问用户赋予管理员权限,还不行。检查system.config,web.config,没发现任何异常。替换oracle本身提供的provider也不行。重启IIS,重启3w服务,重启机器,怎么折腾都不行。真是郁闷古今同啊。最后,已经准备做换机器这样无奈的打算了。还好,在绝望之前又仔细检查了一些细节。

windows 2000和2003的ASP.NET 的体系结构其实是有结构上的差异的。在 Windows 2000 上,多个 Web 应用程序运行于 ASP.NET 工作进程 (Aspnet_wp.exe) 的单个实例中。每个应用程序驻留在其自己的应用程序域中,该域为托管节点提供一定程度的隔离。而在 Windows Server 2003 上,体系结构发生更改,因为 IIS 6 允许使用多个进程来驻留独立的 Web 应用程序。与 Windows 2000 下的 ASP.NET 体系结构相比,Windows Server
2003 中的ASP.NET 体系结构的主要区别在于可以使用单独的 IIS 工作进程实例 (W3wp.exe) 来驻留 Web 应用程序。默认情况下,所有的应用程序都在默认应用程序池中运行。

所以,对默认的应用程序池的配置又做了最后一次详细的检查,在默认的应用程序池属性中标识页,发现有一个预定义帐户选项,列出了三个选项:网络服务 (NetworkService)、本地系统 (LocalSystem)、本地服务 (LocalService) 。当前选中的网络服务,而该帐户是这三个帐户权限最低的,将选项改为本地系统,重启IIS,久违的输入框出现了,终于正常连接到数据库。

小结:如果问题确认出现在环境上,那么就仔细检查每一个细节,以及每一个可能相关的配置项。

 总结:解决方案:第一步,在oracle安装目录(d:/oracle/ora92)上右键,属性->安全,选中Authenticated Users将权限的读取和运行项的勾去掉再打上,然后点击应用,再点击高级确定该用户应用于该文件夹,子文件夹及文件;第二步在ISS中相应项目的应用程序池上右键属性,点标识标签,在预定义帐户项选本地系统,然后重启ISS,OK,登录正常。

抱歉!评论已关闭.