Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Questo contenuto non è disponibile nella lingua selezionata.
Chapter 84. LDAP
LDAP Component Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
The ldap component allows you to perform searches in LDAP servers using filters as the message payload. This component uses standard JNDI (
javax.naming
package) to access the server.
URI format Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
ldap:ldapServerBean[?options]
ldap:ldapServerBean[?options]
The ldapServerBean portion of the URI refers to a DirContext bean in the registry. The LDAP component only supports producer endpoints, which means that an
ldap
URI cannot appear in the from
at the start of a route.
You can append query options to the URI in the following format,
?option=value&option=value&...
Options Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
Name | Default Value | Description |
---|---|---|
base
|
ou=system
|
The base DN for searches. |
scope
|
subtree
|
Specifies how deeply to search the tree of entries, starting at the base DN. Value can be object , onelevel , or subtree .
|
pageSize
|
No paging used. |
When specified the LDAP module uses paging to retrieve all results (most LDAP Servers throw an exception when trying to retrieve more than 1000 entries in one query). To be able to use this, an LdapContext (subclass of DirContext ) has to be passed in as ldapServerBean (otherwise an exception is thrown)
|
returnedAttributes
|
Depends on LDAP Server (could be all or none) . | Comma-separated list of attributes that should be set in each entry of the result |
Result Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
The result is returned in the Out body as a
ArrayList<javax.naming.directory.SearchResult>
object.
DirContext Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
The URI,
ldap:ldapserver
, references a Spring bean with the ID, ldapserver
. The ldapserver
bean may be defined as follows:
The preceding example declares a regular Sun based LDAP
DirContext
that connects anonymously to a locally hosted LDAP server.
Note
DirContext
objects are not required to support concurrency by contract. It is therefore important that the directory context is declared with the setting, scope="prototype"
, in the bean
definition or that the context supports concurrency. In the Spring framework, prototype
scoped objects are instantiated each time they are looked up.
Samples Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
Following on from the Spring configuration above, the code sample below sends an LDAP request to filter search a group for a member. The Common Name is then extracted from the response.
If no specific filter is required - for example, you just need to look up a single entry - specify a wildcard filter expression. For example, if the LDAP entry has a Common Name, use a filter expression like:
(cn=*)
(cn=*)
Binding using credentials Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
A Camel end user donated this sample code he used to bind to the ldap server using credentials.
Configuring SSL Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
All that is required is to create a custom socket factory and reference it in the
InitialDirContext
bean, as shown in the following example:
The
CustomSocketFactory
class is implemented as follows: