Aki, I will open an improvement jira for camel-ldap. For reference, what platform and what ldap server are you using?
Thanks, Hadrian On May 12, 2011, at 1:56 PM, Aki Ristkari wrote: > Hi! > > > I'm working on a system that must periodically grab bunch of users from LDAP > and pass them along via different processors. However the problem is that I > have >1500 users and this causes problems. > > Camel-LDAP states that InitialDirContext to be passed to LDAP-bean but in > case I want to use 'pageSize' option to page the results I need to pass in > LdapContext. Now there is high probability that I just suck but I'm having > troubles getting this to work. > > Now first my route is like this (I stripped unnecessary stuff out of it). > > <camel:route> > <camel:from uri="activemq:queue:UserQueue"/> > <camel:to > uri="ldap:ldapserver?base=ou=people,o=sevenSeas&scope=subtree&pageSize=250"/> > <camel:to uri="bean:ldapProcessor"/> > </camel:route> > > > > If I define 'ldapserver' like this and pass in InitialDirContext: > > <bean id="ldapserver" class="javax.naming.directory.InitialDirContext" > scope="prototype"> > <constructor-arg> > <props> > <prop > key="javax.naming.factory.initial">com.sun.jndi.ldap.LdapCtxFactory</prop> > <prop key="javax.naming.provider.url">ldap://localhost:389</prop> > <prop key="javax.naming.security.authentication">simple</prop> > <prop key="javax.naming.REFERRAL">ignore</prop> > <prop key="javax.naming.SECURITY_AUTHENTICATION">simple</prop> > <prop > key="javax.naming.security.SECURITY_PRINCIPAL">uid=admin,ou=system</prop> > <prop > key="javax.naming.security.SECURITY_CREDENTIALS">secret</prop> > </props> > </constructor-arg> > </bean> > > > It work but fails when there are too many users (ie. when the servers > configured max-size is reched). > > > My next attempt is to use LdapContext like this: > > <bean id="ldapServer" class="javax.naming.ldap.InitialLdapContext"> > <constructor-arg index="0" type="java.util.Hashtable"> > <map> > <entry key="java.naming.factory.initial" > value="com.sun.jndi.ldap.LdapCtxFactory"/> > <entry key="java.naming.provider.url" > value="ldap://localhost:389"/> > <entry key="javax.naming.security.authentication" > value="simple"/> > <entry key="javax.naming.REFERRAL" value="ignore"/> > <entry key="javax.naming.SECURITY_AUTHENTICATION" > value="simple"/> > <entry key="javax.naming.security.SECURITY_PRINCIPAL" > value="uid=admin,ou=system"/> > <entry key="javax.naming.security.SECURITY_CREDENTIALS" > value="secret"/> > </map> > </constructor-arg> > <constructor-arg index="1"> > <null/> > </bean> > > > I construct the environment for LdapContext and null for Controls. I assume > that 'pageSize=250' on the route definition should take care of that. > This works but throws exception: Stack trace: > javax.naming.SizeLimitExceededException: [LDAP: error code 4 - Sizelimit > Exceeded]; > > > > My second attempt is to insert 'PagedResultsControl' for 'LdapContext' like > this: > > <bean id="sc" class="javax.naming.ldap.PagedResultsControl"> > <constructor-arg index="0"> > <value>250</value> > </constructor-arg> > <constructor-arg index="1"> > <value>true</value> > </constructor-arg> > </bean> > > > <bean id="ldapServer" class="javax.naming.ldap.InitialLdapContext"> > <constructor-arg index="0" type="java.util.Hashtable"> > <map> > <entry key="java.naming.factory.initial" > value="com.sun.jndi.ldap.LdapCtxFactory"/> > <entry key="java.naming.provider.url" > value="ldap://localhost:389"/> > <entry key="javax.naming.security.authentication" > value="simple"/> > <entry key="javax.naming.REFERRAL" value="ignore"/> > <entry key="javax.naming.SECURITY_AUTHENTICATION" > value="simple"/> > <entry key="javax.naming.security.SECURITY_PRINCIPAL" > value="uid=admin,ou=system"/> > <entry key="javax.naming.security.SECURITY_CREDENTIALS" > value="secret"/> > </map> > </constructor-arg> > <constructor-arg index="1"> > <ref bean="sc"/> > </constructor-arg> > </bean> > > However this defies logic since I don't want to set the pageSize in these > bean-definitions but in the route. > > > I've tried reading the docs but quite frankly those are quite scattered and > mostly deal with Java-DSL. Any help would be much appreciated! > > > Br, > Ojis
