托管 ODP.net:更改通知和 ldap
Managed ODP.net: change notification and ldap
我正在使用 LDAP 解析连接到 Oracle 数据库。
这对于常规查询现在工作正常,我可以打开一个连接并针对它执行命令。
不幸的是,它不适用于更改通知查询,我在调用 ExecuteNonQuery
时收到 System.DirectoryServices.Protocols.DirectoryOperationException: The object does not exist
异常。
C:\程序Files\Oracle\sqlnet.ora
NAMES.DEFAULT_DOMAIN = mydomain.com
NAMES.DIRECTORY_PATH = (LDAP)
C:\程序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
web.config
<!-- 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)
Trace(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.
对于那些可能遇到相同问题的人,似乎需要 EZConnect 才能允许托管 ODP.net 的更改通知,因此 Web.Config 文件应包含以下行:
<setting name="NAMES.DIRECTORY_PATH" value="(LDAP, EZConnect)"/>
我正在使用 LDAP 解析连接到 Oracle 数据库。
这对于常规查询现在工作正常,我可以打开一个连接并针对它执行命令。
不幸的是,它不适用于更改通知查询,我在调用 ExecuteNonQuery
时收到 System.DirectoryServices.Protocols.DirectoryOperationException: The object does not exist
异常。
C:\程序Files\Oracle\sqlnet.ora
NAMES.DEFAULT_DOMAIN = mydomain.com
NAMES.DIRECTORY_PATH = (LDAP)
C:\程序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
web.config
<!-- 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)
Trace(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.
对于那些可能遇到相同问题的人,似乎需要 EZConnect 才能允许托管 ODP.net 的更改通知,因此 Web.Config 文件应包含以下行:
<setting name="NAMES.DIRECTORY_PATH" value="(LDAP, EZConnect)"/>