7 Replies Latest reply on May 14, 2013 3:40 AM by jaigates vg

    Unable to configure LDAP in Teiid

    jaigates vg Newbie

      Hi,

       

      I m trying to configure ldap in teiid, but i m getting the following exception,

       

       

      13:31:49,275 INFO  (HDScanner)  [org.teiid.RUNTIME] VDB "ldapEDS.1[ldapCon[ldap-connector/translatorldap/java:ldapDS]]" deployed in inactive state.

      13:31:49,275 TRACE (HDScanner)  [org.teiid.deployers.VDBDeployer] Deployed:  vfsfile:/C:/soa-p-5.3.1.GA/jboss-soa-p-5/jboss-as/server/default/deploy/ldapConf-vdb.xml

      13:31:49,275 INFO  (JBoss System Threads(1)-4)  [org.teiid.RUNTIME] VDB ldapEDS.1 model ldapCon metadata is currently being loaded. Start Time: 08/05/13 13:31

      13:32:04,291 WARN  (JBoss System Threads(1)-4)  [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Throwable while attempting to get a new connection: null

      javax.resource.ResourceException: Initializing LDAP directory context failed. Please check LDAP connection properties, including username and password: 172.10.0.1; socket closed

                at org.teiid.resource.adapter.ldap.LDAPConnectionImpl.initializeLDAPContext(LDAPConnectionImpl.java:138)

                at org.teiid.resource.adapter.ldap.LDAPConnectionImpl.<init>(LDAPConnectionImpl.java:73)

                at org.teiid.resource.adapter.ldap.LDAPManagedConnectionFactory$1.getConnection(LDAPManagedConnectionFactory.java:45)

                at org.teiid.resource.adapter.ldap.LDAPManagedConnectionFactory$1.getConnection(LDAPManagedConnectionFactory.java:42)

                at org.teiid.resource.spi.BasicManagedConnectionFactory.createManagedConnection(BasicManagedConnectionFactory.java:70)

                at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:650)

                at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:273)

                at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:689)

                at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:404)

                at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:381)

                at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:496)

                at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)

                at org.teiid.resource.spi.WrappedConnectionFactory.getConnection(WrappedConnectionFactory.java:53)

                at org.teiid.translator.ExecutionFactory.getConnection(ExecutionFactory.java:163)

                at org.teiid.translator.ExecutionFactory.getConnection(ExecutionFactory.java:184)

                at org.teiid.dqp.internal.datamgr.ConnectorManager.getMetadata(ConnectorManager.java:121)

                at org.teiid.deployers.VDBDeployer.loadMetadata(VDBDeployer.java:354)

                at org.teiid.deployers.VDBDeployer.access$000(VDBDeployer.java:60)

                at org.teiid.deployers.VDBDeployer$1.run(VDBDeployer.java:320)

                at org.jboss.util.threadpool.RunnableTaskWrapper.run(RunnableTaskWrapper.java:147)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                at java.lang.Thread.run(Thread.java:619)

       

      ds.xml

       

      <connection-factories>

        <no-tx-connection-factory>

           <jndi-name>ldapDS</jndi-name>

           <rar-name>teiid-connector-ldap.rar</rar-name>

           <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>     

           <config-property name="LdapUrl">172.10.0.1</config-property>

           <config-property name="LdapAdminUserDN">user</config-property>

           <config-property name="LdapAdminUserPassword">user</config-property>

           <config-property name="LdapTxnTimeoutInMillis">-1</config-property>

           <max-pool-size>20</max-pool-size>

         </no-tx-connection-factory>

      </connection-factories>

       

       

      VDB.xml

       

      <property name="UseConnectorMetadata" value="cached" />

          <model type="PHYSICAL" visible="true" name="ldapCon">

                    <property name="importer.useFullSchemaName" value="false"/>

              <source name="ldap-connector" translator-name="translatorldap" connection-jndi-name="java:ldapDS" />

          </model>

                <translator name="translatorldap" type="ldap"/>

       

      kindly provide us the solution.

        • 1. Re: Unable to configure LDAP in Teiid
          Ramesh Reddy Master

          ds.xml file properties like url format is wrong. See /jboss-5.1.0.GA/server/default/teiid-examples/jca/ldap-ds.xml for a  sample.

          • 2. Re: Unable to configure LDAP in Teiid
            jaigates vg Newbie

            Though i gave the correct url , i  m getting the exception which i mentioned earlier

            • 3. Re: Unable to configure LDAP in Teiid
              jaigates vg Newbie

              Hi,

               

              The problem is bcoz of keystore issue. i Solved that one.

               

              i tried connect through SQL developer, but its not showing any tables inside.

               

              when i use the same configuration in active directory service, i can see all the schema avaiable.

               

              Could u pls help me on this?

              • 4. Re: Unable to configure LDAP in Teiid
                Ramesh Reddy Master

                LDAP translator is not capable of defining the metadata automatically, you would have define the metadata in vdb.xml file. See this https://community.jboss.org/message/742528 as to how define metadata. Once you do this you will see the tables

                1 of 1 people found this helpful
                • 6. Re: Unable to configure LDAP in Teiid
                  jaigates vg Newbie

                  refer that link, still facing errors, posted comment on same discusion https://community.jboss.org/message/817287#817287

                  • 7. Re: Unable to configure LDAP in Teiid
                    jaigates vg Newbie

                    yup now i have solved the BASIC DEPLOYMENT ISSUE

                    with code :

                     

                     

                    package com.ldap.translator;

                     

                    import java.io.PrintStream;

                    import java.util.Hashtable;

                    import javax.naming.NamingEnumeration;

                    import javax.naming.NamingException;

                    import javax.naming.directory.Attributes;

                    import javax.naming.directory.InitialDirContext;

                    import javax.naming.ldap.LdapContext;

                    import org.apache.log4j.Logger;

                    import org.teiid.language.Call;

                    import org.teiid.language.Command;

                    import org.teiid.language.QueryExpression;

                    import org.teiid.metadata.Column;

                    import org.teiid.metadata.Datatype;

                    import org.teiid.metadata.MetadataFactory;

                    import org.teiid.metadata.RuntimeMetadata;

                    import org.teiid.metadata.Table;

                    import org.teiid.translator.ExecutionContext;

                    import org.teiid.translator.ProcedureExecution;

                    import org.teiid.translator.ResultSetExecution;

                    import org.teiid.translator.Translator;

                    import org.teiid.translator.TranslatorException;

                    import org.teiid.translator.UpdateExecution;

                    import org.teiid.translator.ldap.LDAPExecutionFactory;

                     

                    @Translator(name="translator-security-ldap")

                    public class SecurityLdapTranslator extends LDAPExecutionFactory

                    {

                      private static final Logger logger = Logger.getLogger(SecurityLdapTranslator.class.getName());

                     

                      public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, LdapContext context) throws TranslatorException

                      {

                        logger.debug("SecurityLdapTranslator createResultSetExecution");

                        return super.createResultSetExecution(command, executionContext, metadata, context);

                      }

                     

                      public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, LdapContext connection) throws TranslatorException

                      {

                        logger.debug("SecurityLdapTranslator createProcedureExecution");

                        return super.createProcedureExecution(command, executionContext, metadata, connection);

                      }

                     

                      public UpdateExecution createUpdateExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, LdapContext context) throws TranslatorException

                      {

                        logger.debug("SecurityLdapTranslator createUpdateExecution");

                        return super.createUpdateExecution(command, executionContext, metadata, context);

                      }

                     

                      public void getMetadata(MetadataFactory metadataFactory, LdapContext conn)

                        throws TranslatorException

                      {

                        Table table = metadataFactory.addTable("people");

                     

                        table.setNameInSource("uid=admin,ou=system");

                     

                        Datatype dt = new Datatype();

                     

                        dt.setDatatypeID("string");

                     

                        Column column1 = new Column();

                     

                        column1.setDatatype(dt);

                     

                        column1.setNameInSource("cn");

                     

                        column1.setName("Name");

                     

                        table.addColumn(column1);

                      }

                     

                      public static void main(String[] args)

                      {

                        Hashtable env = new Hashtable();

                     

                        env.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");

                        env.put("java.naming.provider.url", "ldap://localhost:10389/ou=groups,ou=system");

                     

                        env.put("java.naming.security.principal", "uid=admin,ou=system");

                        env.put("java.naming.security.credentials", "secret");

                        env.put("java.naming.security.authentication", "simple");

                        try {

                          InitialDirContext ctx = new InitialDirContext(env);

                          LdapContext ldapCtx = (LdapContext)ctx.lookup("ou=groups,ou=system");

                          ldapCtx.search("", "", null);

                          Attributes attrs = ctx.getAttributes("");

                          NamingEnumeration enm = attrs.getAll();

                          while (enm.hasMore())

                            System.out.println(enm.next());

                        }

                        catch (NamingException e)

                        {

                          e.printStackTrace();

                        }

                      }

                    }

                     

                    and vdb.xml

                     

                        <model type="PHYSICAL" visible="true" name="security_ldap">
                            <property name="importer.useFullSchemaName" value="false"/>
                            <source name="security_ldap" connection-jndi-name="java:ldap-ds" translator-name="security_ldap.delegated-translator"/>
                        </model>

                     

                        <translator name="security_ldap.delegated-translator"  type="translator-security-ldap">
                            <property name="DelegateName" value="security_ldap.delegating-translator"/>
                        </translator>

                     

                    and java:ldap-ds

                     


                    <connection-factories>

                     

                       <no-tx-connection-factory>
                          <!-- The jndi name of the DataSource -->
                          <jndi-name>ldap-ds</jndi-name>
                         
                          <!-- The resource archive file that defines JCA connection for Sales Force (do not change this) -->
                          <rar-name>teiid-connector-ldap.rar</rar-name>
                          <!-- connection interface; (do not change this) -->
                          <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>     

                     

                           <!-- LDAP Directroy URL (required)-->
                          <config-property name="LdapUrl">ldap://localhost:10389</config-property>
                         
                          <!-- Ldap Admin User DN (required)-->
                          <config-property name="LdapAdminUserDN">uid=admin,ou=system</config-property>
                        
                          <!-- Ldap Admin Password (required)-->
                          <config-property name="LdapAdminUserPassword">secret</config-property>
                        
                          <!-- Ldap Transaction Timeout (ms) -1 = no time out (optional) -->
                          <config-property name="LdapTxnTimeoutInMillis">-1</config-property>
                               
                          <max-pool-size>20</max-pool-size>
                      
                        </no-tx-connection-factory>

                     

                    </connection-factories>

                     

                     

                    BUT coming back to the question of custom translator, created a fresh thread on custom translator and to know best way to use LDAP as datasouce in https://community.jboss.org/thread/228165