luczak (16) [Avatar] Offline
Hi there,

I was wondering if there will be any chapter on accessing LDAP directory? If not, could you show me a simple example on how to properly use this component (preferably in pure Java, without Spring). Also, do you know how to login to LDAP using Camel? As far as I know LDAP's URI format only supports base and scope as options. Thanks in advance
davsclaus (405) [Avatar] Offline
Re: accessing LDAP
the camel-ldap component will not be covered in the book.

You can check the source code for the component and see the unit tests to see a Java based example.
luczak (16) [Avatar] Offline
Re: accessing LDAP
Thanks for the files. I'm still not sure if its possible to bind to LDAP using some DN [Distinguished Name] (since I'm not using anonymous access)? If it's possible, could you paste a short howto-snippet?
davsclaus (405) [Avatar] Offline
Re: accessing LDAP
I did now write the camel-ldap component.

In the past I have used the powerful Spring LDAP template framework

It can bind using credentials.

I will create a JIRA ticket at Apache Camel to look into how to bind using a DN.
davsclaus (405) [Avatar] Offline
Re: accessing LDAP
luczak (16) [Avatar] Offline
Re: accessing LDAP
great, thanks!
jwagenleitner (1) [Avatar] Offline
Re: accessing LDAP
The following works for me in order to bind using credentials using 2.3.0 and in 2.5-SNAPSHOT

Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
props.setProperty(Context.PROVIDER_URL, "ldap://localhost:389");
props.setProperty(Context.URL_PKG_PREFIXES, "com.sun.jndi.url");
props.setProperty(Context.REFERRAL, "ignore");
props.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
props.setProperty(Context.SECURITY_PRINCIPAL, "cn=Manager");
props.setProperty(Context.SECURITY_CREDENTIALS, "secret");

SimpleRegistry reg = new SimpleRegistry();
reg.put("myldap", new InitialLdapContext(props, null));

CamelContext context = new DefaultCamelContext(reg);
new RouteBuilder() {
public void configure() throws Exception {

ProducerTemplate template = context.createProducerTemplate();

Endpoint endpoint = context.getEndpoint("direct:start");
Exchange exchange = endpoint.createExchange();
Exchange out = template.send(endpoint, exchange);

Collection<SearchResult> data = out.getOut().getBody(Collection.class);
assert data != null;
assert !data.isEmpty();


442968 (1) [Avatar] Offline
Any examples to do create/delete operations in LDAP using apache camel?