我正在使用 LDAP 解析连接到 Oracle 数据库。
这对于常规查询现在很好用,我可以打开一个连接并对其执行命令。
不幸的是,它不适用于在调用System.DirectoryServices.Protocols.DirectoryOperationException: The object does not exist
时出现异常的更改通知查询。ExecuteNonQuery
C:\Program Files\Oracle\sqlnet.ora
NAMES.DEFAULT_DOMAIN = mydomain.com
NAMES.DIRECTORY_PATH = (LDAP)
C:\Program Files\Oracle\ldap.ora
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)
跟踪(ips已被xs替换)
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.