VS 2017 - .NET 4.5 - Oracle Managed Client 18.3 - LDAP and entity framework

ReubenC

    Hello,

    I am trying to create an entity framework model from an Oracle database using LDAP.  I am using the managed client version 18.3.

    I cannot seem to get the entity framework to recognize an Oracle database through LDAP.  It sees databases in TNS fine.

    In particular, if you look at the choose your data connection window in the Entity Data Model Wizard, how do I connect to an Oracle server through LDAP there? (screenshot of particular window available upon request) Or how can I tell it to use the correct connection in the app.config?

    Do I need to add an additional connection string by editing app.config?

    Does anyone know how to do this?

     

    I think I was able to force it through in Visual Studio 2015, but Visual Studio 2017 no longer allows this.

     

    in app.config:

     

    add name="dbnameEntities" connectionString="metadata=res://*/DatabridgeModel1.csdl|res://*/DatabridgeModel1.ssdl|res://*/DatabridgeModel1.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string="DATA SOURCE=DATASOURCENAMESID;PASSWORD=password;USER ID=userid"" providerName="System.Data.EntityClient" />

     

    The following settings are under:

     

    <oracle.manageddataaccess.client>

         <version number="*">

     

    <LDAPsettings>

    <LDAPsetting name="DIRECTORY_SERVERS" value="(ldapserver1.fqdn.com,ldapserver2.fqdn.com)"/>

    <LDAPsetting name="DIRECTORY_SERVER_TYPE" value="oid"/>

    <LDAPsetting name="DEFAULT_ADMIN_CONTEXT" value="dc=fqdn,dc=com"/>

    <LDAPsettings>

     

    I tried to use the above or the below (not both at the same time)

     

    <settings>

         <setting name="LDAP_ADMIN" value="C:\app\client\windowsuser\product\12.1.0\client_1\NETWORK\ADMIN"/>

         <setting name="NAMES.DIRECTORY_PATH" value="(LDAP)"/>

    <settings>

     

     

    Final note, Oracle itself and the TNS_ADMIN OS variable are set correctly.  I am able to tnsping (DATASOURCENAMESID in the above example)  the instance using ldap to resolve.

      • 1. Re: VS 2017 - .NET 4.5 - Oracle Managed Client 18.3 - LDAP and entity framework
        Alex Keh - Product Manager-Oracle

        It shouldn't matter whether you are using VS 2015 or 2017. The EF6 app runs in .NET FW, not the IDE.

         

        One thing I noticed is that your LDAP_ADMIN is pointing to your 12.1 Home/Network/Admin directory, not the 18.3 Home. That tells me you may have leftover places of other Oracle configuration files on the machine. It's possible you have a stray ldap.ora somewhere that overrides the .NET configuration file settings.

         

        You could then try putting our ldap.ora in the same location as where you've placed your tnsnames.ora and sqlnet.ora.

        • 2. Re: VS 2017 - .NET 4.5 - Oracle Managed Client 18.3 - LDAP and entity framework
          ReubenC

          I realized I should use the LDAPSettings instead of getting it from a particular location as this will be deployed to a server that may or may not have ldap set up.
          Ideally, I would like to have the application independent of what is on the server or my computer (why I'm using managed client) as otherwise I run into driver issues.  This also means I don't have to be bothered with what is or is not on the server.

          All of the ldap settings are the same, but shouldn't setting them specifically using ldapsetting in app.config override them? How should my config look to keep it independent?

          <LDAPsettings>

          <LDAPsetting name="DIRECTORY_SERVERS" value="(ldapserver1.fqdn.com,ldapserver2.fqdn.com)"/>

          <LDAPsetting name="DIRECTORY_SERVER_TYPE" value="oid"/>

          <LDAPsetting name="DEFAULT_ADMIN_CONTEXT" value="dc=fqdn,dc=com"/>

          <LDAPsettings>

           

          The big problem I have is how to setup a new entity framework model with an ldap database as the entity data model wizard/new connection properties are not aware of ldap.

          • 3. Re: VS 2017 - .NET 4.5 - Oracle Managed Client 18.3 - LDAP and entity framework
            ReubenC

            I attempted to just use datasets to see if it was a problem with LDAP vs entity framework.  I was able to setup a connection to the database through LDAP fine when using data adapters and data sets. It's just the entity framework setup does not seem to allow for it in a straightforward manner.

             

            I made sure that it was using the configuration in app.config by temporarily disabling LDAP on any local Oracle clients.

             

            If I am using an existing database, how do I get Entity Framework to connect through LDAP?  Building the connection string from the one I created for the data adapter just gives me connection timed out.

            • 4. Re: VS 2017 - .NET 4.5 - Oracle Managed Client 18.3 - LDAP and entity framework
              Alex Keh - Product Manager-Oracle

              As EF relies on the DbProviderFactory class, perhaps the factory class does not use provider-specific configuration in the .NET config file. Can you try setting your directory settings in ldap.ora instead?

              • 5. Re: VS 2017 - .NET 4.5 - Oracle Managed Client 18.3 - LDAP and entity framework
                ReubenC

                The 12.1 LDAP configuration from the original post that I was pointing to matches the provider specific settings.

                 

                As far as if the factory class uses the provider specific configuration in the .net config file, is there a way we can find out?

                 

                Does this mean I should discuss with the server administrator to get the LDAP configuration working on the server?

                I was hoping to avoid that as that is an additional level of complexity.

                • 6. Re: VS 2017 - .NET 4.5 - Oracle Managed Client 18.3 - LDAP and entity framework
                  Alex Keh - Product Manager-Oracle

                  You can try connecting to Oracle DB through a non-EF app using the factory classes. If that doesn't work, then it's likely a factory class limitation not being able to use provider-specific config settings.

                   

                  When you set the LDAP settings, do so without using the any of the app.config settings. That means you can't use:

                       <setting name="LDAP_ADMIN" value="C:\app\client\windowsuser\product\12.1.0\client_1\NETWORK\ADMIN"/>

                  You can place your *.ora files in your current working directory, where there's a Windows environment variable for TNS_ADMIN set (or LDAP_ADMIN if it's just ldap.ora).