我使用LDAP解析连接到Oracle数据库。
现在对常规查询工作正常,我可以打开连接并对其执行命令。
不幸的是,它不适用于在调用System.DirectoryServices.Protocols.DirectoryOperationException: The object does not exist
时我收到ExecuteNonQuery
异常的更改通知查询。
NAMES.DEFAULT_DOMAIN = mydomain.com
NAMES.DIRECTORY_PATH = (LDAP)
DIRECTORY_SERVERS=(oidgv0.mydomain.com:3060:3131,oidgv1.mydomain.com:3060:3131)
DEFAULT_ADMIN_CONTEXT="dc=mydomain,dc=com"
DIRECTORY_SERVER_TYPE=OID
<!-- ODP.net configuration -->
<oracle.manageddataaccess.client>
<version number="*">
<settings>
<setting name="ldap_admin" value="C:\Program Files\Oracle" />
<setting name="NAMES.DIRECTORY_PATH" value="(LDAP)"/>
</settings>
</version>
</oracle.manageddataaccess.client>
<!-- Database connections configuration -->
<connectionStrings>
<add name="MyDB" connectionString="Data Source=MyDB_Alias;User ID=..." />
</connectionStrings>
string connectionString = ConfigurationManager.ConnectionStrings["MyDB"].
ConnectionString;
var connection = new OracleConnection(connectionString);
connection.Open(); // This works fine
OracleCommand command = connection.CreateCommand();
command.CommandText = "select * from my_table";
var dependency = new OracleDependency(
command, isNotifiedOnce: false, timeout: 0, isPersistent: false);
dependency.QueryBasedNotification = false;
dependency.OnChange += OnChangeHandler;
command.ExecuteNonQuery(); // The exception is thrown during this call
引发以下异常:
Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-12154: TNS:could not resolve the connect identifier specified ---> OracleInternal.Network.NetworkException (0x00002F7A): ORA-12154: TNS:could not resolve the connect identifier specified
at OracleInternal.Network.AddressResolution..ctor(String TNSAlias, String instanceName)
at OracleInternal.Network.OracleCommunication.Listen(String tnsDescriptor, Boolean inAddr_Any)
2015-04-30 15:11:02.017271 TID:1 (NET) LDAP.Resolve(): query oidgv0.mydomain.com for cn=10,cn=OracleContext,dc=x,dc=x,dc=x:x
2015-04-30 15:11:02.075276 TID:1 (NET) Exception during OracleInternal.Network.LDAP.Resolve : System.DirectoryServices.Protocols.DirectoryOperationException: The object does not exist.
at System.DirectoryServices.Protocols.LdapConnection.ConstructResponse(Int32 messageId, LdapOperation operation, ResultAll resultType, TimeSpan requestTimeOut, Boolean exceptionOnTimeOut)
at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request, TimeSpan requestTimeout)
at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request)
at OracleInternal.Network.LDAP.Resolve(String TNSname, ConnectionOption& CO, String IN)
2015-04-30 15:11:02.298299 TID:1 (NET) LDAP.Resolve(): query oidgv1.mydomain.com for cn=10,cn=OracleContext,dc=x,dc=x,dc=x:x
2015-04-30 15:11:02.425311 TID:1 (NET) Exception during OracleInternal.Network.LDAP.Resolve : System.DirectoryServices.Protocols.DirectoryOperationException: The object does not exist.
at System.DirectoryServices.Protocols.LdapConnection.ConstructResponse(Int32 messageId, LdapOperation operation, ResultAll resultType, TimeSpan requestTimeOut, Boolean exceptionOnTimeOut)
at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request, TimeSpan requestTimeout)
at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request)
at OracleInternal.Network.LDAP.Resolve(String TNSname, ConnectionOption& CO, String IN)
2015-04-30 15:11:02.425311 TID:1 (NET) LDAP.Resolve(): x.x.x.x:x is not valid for LDAP Naming Adapter.
答案 0 :(得分:1)
对于那些可能遇到同样问题的人来说,似乎EZConnect需要允许使用托管ODP.net进行更改通知,因此Web.Config文件应包含以下行:
<setting name="NAMES.DIRECTORY_PATH" value="(LDAP, EZConnect)"/>