0

经过广泛的谷歌搜索后,我似乎无法找到解决此问题的方法。简而言之,我在 MVC/Web API 应用程序中使用带有 EF 6 的 Oracle 托管数据访问客户端。

当我在本地运行时,我可以成功调用 Web API 2 控制器中的各种操作。没问题。

当我发布到我们的登台服务器时,我立即收到此错误:

“消息:底层提供程序在打开时失败。-Inner:Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-01017: 用户名/密码无效;在 OracleInternal.ConnectionPool.PoolManager 处登录被拒绝\r\n

显然,当我在本地运行时,用户名/密码很好,所以我觉得我错过了将它们放入我的 web.config 中的某个位置。

这是我的网络配置,您可以看到我使用整个 TNS 字符串作为连接字符串中的数据源值。如果我不这样做,登台站点会显示错误 - TNS:could not resolve the connect identifier specified

<configuration>
  <configSections>
   <section name="entityFramework"  type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
   <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
<connectionStrings>
<add name="EISContext" connectionString="metadata=res://*/EISModel.csdl|res://*/EISModel.ssdl|res://*/EISModel.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string=&quot;DATA SOURCE=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 123.west.dc) (PORT = 1540)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = tst)));PASSWORD=password;USER ID=username&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.data>
<DbProviderFactories>
  <remove invariant="Oracle.DataAccess.Client" />
  <add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess" />
  <remove invariant="Oracle.ManagedDataAccess.Client" />
  <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess" />
</DbProviderFactories>
</system.data>
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime />
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<system.webServer>
<handlers>
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <remove name="OPTIONSVerbHandler" />
  <remove name="TRACEVerbHandler" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
  </handlers>
  </system.webServer>
  <runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
    <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
  </dependentAssembly>
  <dependentAssembly>
    <publisherPolicy apply="no" />
    <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
  </dependentAssembly>
   </assemblyBinding>
  </runtime>
  <oracle.manageddataaccess.client>
   <version number="*">
   <dataSources>
    <dataSource alias="SampleDataSource" descriptor="(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 123.west.dc) (PORT = 1540)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = tst)))" />
  </dataSources>
  <settings>
    <setting name="DbNotificationPort" value="-1" />
    <setting name="NAMES.DIRECTORY_PATH" value="(TNSNAMES, EZCONNECT)" />
    <setting name="TNS_ADMIN" value="C:\Oracle\product\11.2.0\client_2\network\admin"/>
    <setting name="FetchSize" value="1048576" />
    </settings>
    </version>
    </oracle.manageddataaccess.client>
    <system.codedom>
    <compilers>
    <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
     <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
   </system.codedom>
   <entityFramework>
   <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
   <providers>
    <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
  <provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</providers>
</entityFramework>
</configuration>
4

1 回答 1

0

修复方法是将 reg 中的 FIPSSecurityPolicy 设置为 0,而不是默认值 1。

感谢这个线程:Oracle.ManagedDataAccess 和 ORA-01017:用户名/密码无效;登录被拒绝

于 2016-03-23T16:19:15.890 回答