6 Replies Latest reply on Jul 8, 2011 5:06 AM by Alexandre GUYOT

    can we use the LDAP component to write into a directory ?

    Alexandre GUYOT Newbie

      Apache camel say : "the LDAP component only supports producer endpoints, which means that an ldap URI cannot appear in the from at the start of a route"

       

      But I need to write into my directory, can you give me the best way to do that ?

       

      Thanks, for your help !

       

      Edited by: maulex on Jun 21, 2011 1:36 PM

       

      Edited by: maulex on Jun 21, 2011 1:37 PM

        • 1. Re: can we use the LDAP component to write into a directory ?
          Claus Ibsen Master

          You can use the LDAP API from a java bean to write into the ldap.

           

          There is also a Spring LdapTemplate project that makes it a bit easier to work with ldap

          • 2. Re: can we use the LDAP component to write into a directory ?
            A E Newbie

            I concur, using the spring ldapTemplate as a camel bean endpoint works very well.  I have done this in the past.

            • 3. Re: can we use the LDAP component to write into a directory ?
              Alexandre GUYOT Newbie

              Hi,

               

              I try to run ldapTemplate as endpoint but without success ! I follow this link because it's simple and near to what I would like. But it doesn't work I would like to know if you have a tutorial or exmple to do it into FuseESB !

               

              For information I have this error when a message is send to endpoint :

              -


              ERROR : ultErrorHandler >>> Failed delivery for exchangeId: ID:Q12009038-1358-1309849702445-4:4:1:1:2. Exhausted after delivery attempt: 1 caught: net.sf.ldaptemplate.UncategorizedLdapException: Operation failed; nested exception is javax.naming.NamingException: [LDAP: error code 1 -

              000004DC: LdapErr: DSID-0C0906DC, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v1db0 ]; remaining name ''

              net.sf.ldaptemplate.UncategorizedLdapException: Operation failed; nested exception is javax.naming.NamingException: [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C0906DC, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v1db

              0 ]; remaining name ''

                      at net.sf.ldaptemplate.DefaultNamingExceptionTranslator.translate(DefaultNamingExceptionTranslator.java:93)[240:AdapterActiveDirectory:0.0.1.SNAPSHOT]

                      at net.sf.ldaptemplate.LdapTemplate.search(LdapTemplate.java:216)[240:AdapterActiveDirectory:0.0.1.SNAPSHOT]

                      at net.sf.ldaptemplate.LdapTemplate.search(LdapTemplate.java:186)[240:AdapterActiveDirectory:0.0.1.SNAPSHOT]

                      at net.sf.ldaptemplate.LdapTemplate.search(LdapTemplate.java:385)[240:AdapterActiveDirectory:0.0.1.SNAPSHOT]

                      at net.sf.ldaptemplate.LdapTemplate.search(LdapTemplate.java:262)[240:AdapterActiveDirectory:0.0.1.SNAPSHOT]

                      at net.sf.ldaptemplate.LdapTemplate.search(LdapTemplate.java:283)[240:AdapterActiveDirectory:0.0.1.SNAPSHOT]

                      at com.capgemini.iamfuse.PersonDaoImpl.getAllPersons(PersonDaoImpl.java:33)[240:AdapterActiveDirectory:0.0.1.SNAPSHOT]

                      at com.capgemini.iamfuse.PersonDaoImpl.getAllPersonsExchange(PersonDaoImpl.java:38)[240:AdapterActiveDirectory:0.0.1.SNAPSHOT]

                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_24]

                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_24]

                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_24]

                      at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_24]

                      at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:323)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:225)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:167)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:80)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:80)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:80)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.fabric.FabricTraceProcessor.process(FabricTraceProcessor.java:62)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:80)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:314)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:209)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:269)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:80)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.Pipeline.process(Pipeline.java:125)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:80)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:106)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)[76:org.apache.camel.camel-core:2.7.1.fuse-00-27]

                      at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:93)[91:org.apache.camel.camel-jms:2.7.1.fuse-00-27]

                      at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:560)[92:org.springframework.jms:3.0.5.RELEASE]

                      at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:498)[92:org.springframework.jms:3.0.5.RELEASE]

                      at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:467)[92:org.springframework.jms:3.0.5.RELEASE]

                      at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)[92:org.springframework.jms:3.0.5.RELEASE]

                      at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)[92:org.springframework.jms:3.0.5.RELEASE]

                      at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1058)[92:org.springframework.jms:3.0.5.RELEASE]

                      at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1050)[92:org.springframework.jms:3.0.5.RELEASE]

                      at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:947)[92:org.springframework.jms:3.0.5.RELEASE]

                      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_24]

                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_24]

                      at java.lang.Thread.run(Thread.java:662)[:1.6.0_24]

              Caused by: javax.naming.NamingException: LDAP: error code 1 - 000004DC: LdapErr: DSID-0C0906DC, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v1db0 ; remaining name ''

                      at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3081)[:1.6.0_24]

                      at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2987)[:1.6.0_24]

                      at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2794)[:1.6.0_24]

                      at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1826)[:1.6.0_24]

                      at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1749)[:1.6.0_24]

                      at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)[:1.6.0_24]

                      at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:338)[:1.6.0_24]

                      at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:321)[:1.6.0_24]

                      at org.apache.servicemix.naming.InitialContextWrapper.search(InitialContextWrapper.java:352)

                      at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:248)[:1.6.0_24]

                      at net.sf.ldaptemplate.LdapTemplate$2.executeSearch(LdapTemplate.java:182)[240:AdapterActiveDirectory:0.0.1.SNAPSHOT]

                      at net.sf.ldaptemplate.LdapTemplate.search(LdapTemplate.java:198)[240:AdapterActiveDirectory:0.0.1.SNAPSHOT]

                      ... 51 more

              -


               

              I could solve my problem if i can find a good exemple of using ldapTemplate with FuseESB.

               

              Thanks for your help !

              • 4. Re: can we use the LDAP component to write into a directory ?
                Claus Ibsen Master

                If you ldap server require login then you must setup username/password details.

                 

                Usually when there is a binding error with ldap, that means you cannot login (bind to the ldap server)

                • 5. Re: can we use the LDAP component to write into a directory ?
                  Alexandre GUYOT Newbie

                  Thanks for your help ! I solved my problem, but I have not succeeded to make SSL connection with my directory !

                   

                  the ssl connection with my active directory is my next goal !

                   

                  maulex

                  • 6. Re: can we use the LDAP component to write into a directory ?
                    Alexandre GUYOT Newbie

                    Hi,

                     

                    I made a java code to do my secure connexion over SSL with my ldapTemplate, something like this :

                    -


                    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

                    System.setProperty("javax.net.ssl.trustStore", "C:
                    CERT
                    keystore.jks");

                    -


                     

                    It works ouside as a simple jar but when i bundulize it to work inside Fuse, I have a lot of problem !

                    So my new question is "How to set my keystore in fuse ?"

                    I find a lot of doc to do a SSL socket on jetty but nothing about ldap !

                     

                    My error is :

                    -


                    org.springframework.ldap.CommunicationException: 10.67.100.226:636; nested exception is javax.naming.CommunicationException: 10.67.100.226:636 [Root exception is java.lang.ClassNotFoundException: javax.net.ssl.SSLSocketFactory not found from bundle ]

                            at org.springframework.ldap.support.LdapUtils.convertLdapException(LdapUtils.java:100)

                            at org.springframework.ldap.core.support.AbstractContextSource.createContext(AbstractContextSource.java:266)

                            at org.springframework.ldap.core.support.AbstractContextSource.getContext(AbstractContextSource.java:106)

                            at org.springframework.ldap.core.support.AbstractContextSource.getReadWriteContext(AbstractContextSource.java:138)

                            at org.springframework.ldap.core.LdapTemplate.executeReadWrite(LdapTemplate.java:801)

                            at org.springframework.ldap.core.LdapTemplate.bind(LdapTemplate.java:996)

                            at com.test.PersonDao.addUser(PersonDao.java:131)

                            at com.test.PersonDao.camelAddUser(PersonDao.java:144)

                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                            at java.lang.reflect.Method.invoke(Method.java:597)

                            at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:323)

                            at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:225)

                            at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:167)

                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:80)

                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)

                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)

                            at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)

                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:80)

                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)

                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)

                            at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)

                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:80)

                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)

                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)

                            at org.apache.camel.fabric.FabricTraceProcessor.process(FabricTraceProcessor.java:62)

                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:80)

                            at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:314)

                            at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:209)

                            at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:269)

                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:80)

                            at org.apache.camel.processor.Pipeline.process(Pipeline.java:125)

                            at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)

                            at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)

                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:80)

                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)

                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)

                            at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)

                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:106)

                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)

                            at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:104)

                            at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:49)

                            at java.util.TimerThread.mainLoop(Timer.java:512)

                            at java.util.TimerThread.run(Timer.java:462)

                    Caused by: javax.naming.CommunicationException: 10.67.100.226:636 [Root exception is java.lang.ClassNotFoundException: javax.net.ssl.SSLSocketFactory not found from bundle ]

                            at com.sun.jndi.ldap.Connection.(InitialLdapContext.java:134)

                            at org.springframework.ldap.core.support.LdapContextSource.getDirContextInstance(LdapContextSource.java:43)

                            at org.springframework.ldap.core.support.AbstractContextSource.createContext(AbstractContextSource.java:254)

                            ... 43 more

                    Caused by: java.lang.ClassNotFoundException: javax.net.ssl.SSLSocketFactory not found from bundle

                            at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:103)

                            at org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)

                            at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

                            at java.lang.Class.forName0(Native Method)

                            at java.lang.Class.forName(Class.java:247)

                            at com.sun.jndi.ldap.VersionHelper12.loadClass(VersionHelper12.java:57)

                            at com.sun.jndi.ldap.Connection.createSocket(Connection.java:270)

                            at com.sun.jndi.ldap.Connection.(Connection.java:187)

                            ... 59 more

                    Caused by: java.lang.ClassNotFoundException: javax.net.ssl.SSLSocketFactory not found by AdapterActiveDirectory

                            at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:812)

                            at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:72)

                            at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1806)

                            at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

                            at org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:670)

                            at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1613)

                            at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:909)

                            at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:99)

                            ... 66 more

                    -


                     

                    And after this error ServiceMix crash and I'm in Ms-DOS !

                    I think the use of security provider in the bundle do not expect good practice, so if anyone know how to operate this in ServiceMix !