Managed ODP.net: change notification and ldap

1

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.

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

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>

Notification registration

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)

Trace (ips have been replaced with 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.
c#
oracle
ldap
odp.net-managed
change-notification
asked on Stack Overflow Apr 30, 2015 by vc 74

1 Answer

1

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)"/>
answered on Stack Overflow May 1, 2015 by vc 74

User contributions licensed under CC BY-SA 3.0