I'm using the LDAP resolution to connect to an Oracle database.
This works fine now for regular queries, I can open a connection and execute commands against it.
Unfortunately, it does not work for change notification queries for which I get a System.DirectoryServices.Protocols.DirectoryOperationException: The object does not exist
exception when ExecuteNonQuery
is called.
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
Which throws the following exception:
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.
For those who might have the same issue, it seems like EZConnect is required to allow change notifications with managed ODP.net so the Web.Config file should contain the following line:
<setting name="NAMES.DIRECTORY_PATH" value="(LDAP, EZConnect)"/>
User contributions licensed under CC BY-SA 3.0