public class

LDAPConnector

extends Object
java.lang.Object
   ↳ org.mule.module.ldap.LDAPConnector
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

The LDAP Connector will allow to connect to any LDAP server and perform every LDAP operation:

  • bind: Authenticate against the LDAP server. This occurs automatically before each operation but can also be performed on request
  • search: Perform a LDAP search in a base DN with a given filter
  • lookup: Retrieve a unique LDAP entry
  • add: Creates a new LDAP entry
  • add attribute/s: Add specific attributes to an existing LDAP entry
  • modify: Update an existing LDAP entry
  • modify attribute/s: Update specific attributes of an existing LDAP entry
  • delete: Delete an existing LDAP entry
  • delete attribute/s: Delete specific attributes of an existing LDAP entry

In order to be able to use any of the operations listed before, you must define a config element with the LDAP connection parameters:

URL The connection URL to the LDAP server. LDAP connection URLs have the following syntax: ldap[s]://hostname:port/base_dn

  • hostname: Name (or IP address in dotted format) of the LDAP server. For example, ldap.example.com or 192.202.185.90.
  • port: Port number of the LDAP server (for example, 696). If no port is specified, the standard LDAP port (389) or LDAPS port (636) is used.
  • base_dn: distinguished name (DN) of an entry in the directory. This DN identifies the entry that is the starting point of the search. If no base DN is specified, the search starts at the root of the directory tree.
Some examples are:
  • ldap://localhost:389/
  • ldap://localhost:389/dc=mulesoft,dc=org
  • ldaps://localhost:636/dc=mulesoft,dc=org
  • ldaps://ldap.mulesoft.org/
Type The implementation of the connection to be used. Right now the only available implementation is JNDI, though any other implementation can be used (For example using Novell libraries). If you want to create your own implementation you should extend the class LDAPConnection
  • JNDI: Implementation that uses the JNDI interfaces provided in the standard JRE.
Initial Pool Size The string representation of an integer that represents the number of connections per connection identity to create when initially creating a connection for the identity. To disable pooling, just set this value to 0 (zero).
Max Pool Size The string representation of an integer that represents the maximum number of connections per connection identity that can be maintained concurrently.
Pool Timeout The string representation of an integer that represents the number of milliseconds that an idle connection may remain in the pool without being closed and removed from the pool.
Referral Constant that holds the name of the environment property for specifying how referrals encountered by the service provider are to be processed. The value of the property is one of the following strings:
  • follow: Follow referrals automatically
  • ignore: Ignore referrals
  • throw: Throw ReferralException when a referral is encountered.
Extended Configuration This is a Map instance holding extended configuration attributes that will be used in the Context environment. Values configured here have less precedence than the other values that are allowed in the module configuration. Some examples of extended properties (key: value) are:
  • java.naming.language: Constant that holds the name of the environment property for specifying the preferred language to use with the service. The value of the property is a colon-separated list of language tags as defined in RFC 1766.
  • java.naming.security.authentication: Constant that holds the name of the environment property for specifying the security level to use. Its value is one of the following strings: "none", "simple", "strong".
  • java.naming.security.protocol: Constant that holds the name of the environment property for specifying the security protocol to use. Its value is a string determined by the service provider (e.g. "ssl").
  • com.sun.jndi.ldap.connect.pool.authentication: A list of space-separated authentication types of connections that may be pooled. Valid types are "none", "simple", and "DIGEST-MD5".
  • com.sun.jndi.ldap.connect.pool.debug: A string that indicates the level of debug output to produce. Valid values are "fine" (trace connection creation and removal) and "all" (all debugging information).
  • com.sun.jndi.ldap.connect.pool.prefsize: The string representation of an integer that represents the preferred number of connections per connection identity that should be maintained concurrently.
  • com.sun.jndi.ldap.connect.pool.protocol: A list of space-separated protocol types of connections that may be pooled. Valid types are "plain" and "ssl".

{@sample.config INCLUDE_ERROR}

{@sample.config INCLUDE_ERROR}

{@sample.config INCLUDE_ERROR}

Summary

Fields
private static final Logger LOGGER
private LDAPConnection connection
private Map<String, String> extendedConfiguration This is a Map instance holding extended configuration attributes that will be used in the Context environment.
private int initialPoolSize The string representation of an integer that represents the number of connections per connection identity to create when initially creating a connection for the identity.
private int maxPoolSize The string representation of an integer that represents the maximum number of connections per connection identity that can be maintained concurrently.
private long poolTimeout The string representation of an integer that represents the number of milliseconds that an idle connection may remain in the pool without being closed and removed from the pool.
private Referral referral Constant that holds the name of the environment property for specifying how referrals encountered by the service provider are to be processed (follow, ignore, throw).
private Type type The implementation of the connection to be used.
private String url The connection URL to the LDAP server with the following syntax: ldap[s]://hostname:port/base_dn.
Public Constructors
LDAPConnector()
Public Methods
void add(LDAPEntry entry)
Creates a new LDAPEntry in the LDAP server.
void addFromMap(String dn, Map<String, Object> entry)
Creates a new entry in the LDAP server from a Map representation.
void addMultiValueAttribute(String dn, String attributeName, List<Object> attributeValues)
Adds all the values for an attribute in an existing LDAP entry.
void addSingleValueAttribute(String dn, String attributeName, String attributeValue)
Adds a value for an attribute in an existing LDAP entry.
LDAPEntry bind()
Performs an LDAP bind (login) operation.
void connect(String authDn, String authPassword, String authentication)
Establish the connection to the LDAP server and use connection management to handle different users.
String connectionId()
Returns the connection ID
void delete(String dn)
Deletes the LDAP entry represented by the provided distinguished name.
void deleteMultiValueAttribute(String dn, String attributeName, List<Object> attributeValues)
Deletes all the values matching attributeValues of the attribute defined by attributeName.
void deleteSingleValueAttribute(String dn, String attributeName, String attributeValue)
Deletes the value matching attributeValue of the attribute defined by attributeName.
void disconnect()
Disconnect the current connection
Map<String, String> getExtendedConfiguration()
int getInitialPoolSize()
int getMaxPoolSize()
long getPoolTimeout()
Referral getReferral()
Type getType()
String getUrl()
boolean isConnected()
Are we connected?
static String ldapEntryToLdif(LDAPEntry entry)
Transforms a LDAPEntry to a String in LDIF representation (RFC 2849).
static Map<String, Object> ldapEntryToMap(LDAPEntry entry)
Creates the Map representation of an LDAPEntry.
LDAPEntry lookup(String dn, List<String> attributes)
Retrieves an entry from the LDAP server base on its distinguished name (DN).
static LDAPEntry mapToLdapEntry(Map<String, Object> entry)
Creates a LDAPEntry from its Map representation.
void modify(LDAPEntry entry)
Updates an existing LDAPEntry in the LDAP server.
void modifyFromMap(String dn, Map<String, Object> entry)
Updates an existing entry in the LDAP server from a Map representation.
void modifyMultiValueAttribute(String dn, String attributeName, List<Object> attributeValues)
Updates (replaces) the value or values of the attribute defined by attributeName with the new values defined by attributeValues.
void modifySingleValueAttribute(String dn, String attributeName, String attributeValue)
Updates (replaces) the value or values of the attribute defined by attributeName with the new value defined by attributeValue.
List<Object> pagedResultSearch(String baseDn, String filter, List<String> attributes, SearchScope scope, int timeout, long maxResults, boolean returnObject, int pageSize, int resultPageSize, SourceCallback callback)
Performs a LDAP search and streams result to the rest of the flow.
void rename(String oldDn, String newDn)
Renames and existing LDAP entry (moves and entry from a DN to another one).
List<LDAPEntry> search(String baseDn, String filter, List<String> attributes, SearchScope scope, int timeout, long maxResults, boolean returnObject, int pageSize)
Performs a LDAP search returning a list with all the resulting LDAP entries.
LDAPEntry searchOne(String baseDn, String filter, List<String> attributes, SearchScope scope, int timeout, long maxResults, boolean returnObject)
Performs a LDAP search that is supposed to return a unique result.
void setExtendedConfiguration(Map<String, String> extendedConfiguration)
void setInitialPoolSize(int initialPoolSize)
void setMaxPoolSize(int maxPoolSize)
void setPoolTimeout(long poolTimeout)
void setReferral(Referral referral)
void setType(Type type)
void setUrl(String url)
[Expand]
Inherited Methods
From class java.lang.Object

Fields

private static final Logger LOGGER

private LDAPConnection connection

private Map<String, String> extendedConfiguration

This is a Map instance holding extended configuration attributes that will be used in the Context environment.

private int initialPoolSize

The string representation of an integer that represents the number of connections per connection identity to create when initially creating a connection for the identity. To disable pooling, just set this value to 0 (zero).

private int maxPoolSize

The string representation of an integer that represents the maximum number of connections per connection identity that can be maintained concurrently.

private long poolTimeout

The string representation of an integer that represents the number of milliseconds that an idle connection may remain in the pool without being closed and removed from the pool.

private Referral referral

Constant that holds the name of the environment property for specifying how referrals encountered by the service provider are to be processed (follow, ignore, throw).

private Type type

The implementation of the connection to be used.

private String url

The connection URL to the LDAP server with the following syntax: ldap[s]://hostname:port/base_dn.

Public Constructors

public LDAPConnector ()

Public Methods

public void add (LDAPEntry entry)

Creates a new LDAPEntry in the LDAP server. The entry should contain the distinguished name (DN), the objectClass attributes that define its structure and at least a value for all the required attributes (required attributes depend on the object classes assigned to the entry. You can refer to RFC 4519 for standard object classes and attributes.

LDAPEntry object provided with expression

LDAPEntry object provided in payload

Parameters
entry The LDAPEntry that should be added.
Throws
NoPermissionException If the current binded user has no permissions to add entries under any of the RDN (relative DN) that compose the entry DN.
InvalidAttributeException If the structure of the entry is invalid (for example there are missing required attributes or it has attributes that are not part of any of the defined object classes)
NameAlreadyBoundException If there is already an existing entry with the same DN in the LDAP server tree.
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error creating the entry.

public void addFromMap (String dn, Map<String, Object> entry)

Creates a new entry in the LDAP server from a Map representation. The distinguished name (DN) of the entry is first obtained from the optional parameter dn and if this value is blank (null, empty string or string with only space chars) then the DN should be a present in the entry map as a String value under the key "dn" (see MAP_DN_KEY).

In order to represent a LDAP entry as a map, you should consider the following rules for the map key/value pair:

  • Single Value Attributes: The key should be the name of the single value attribute (for example uid, cn, ...) as a String and the value is just the value of the attribute (most of the times represented by a String.
  • Multi-value Attributes: The key should be the name of the multiple values attribute (for example objectClass, memberOf, mail, ...) as a String and the value should be a List holding the multiple values of the attribute. Usually it will be a list of strings.
  • Distinguished name: As an alternative to passing the DN as a separate argument of the operation, you can include it in the entry map. In this case, the key should be the string "dn" (see MAP_DN_KEY) and the value a String representing the distinguished name (for example cn=andy,ou=people,dc=mulesoft,dc=org).

The map is provided as a reference and the DN is not in the map

The map is created in the XML file and the DN is another map entry

The map is provided in the payload and the DN is another map entry

Parameters
dn The primary value to use as DN of the entry. If not set, then the DN will be retrieved from the map representing the entry under the key dn.
entry Map representation of the LDAP entry.
Throws
NoPermissionException If the current binded user has no permissions to add entries under any of the RDN (relative DN) that compose the entry DN.
InvalidAttributeException If the structure of the entry is invalid (for example there are missing required attributes or it has attributes that are not part of any of the defined object classes)
NameAlreadyBoundException If there is already an existing entry with the same DN in the LDAP server tree.
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error creating the entry (for example if the DN is not passed as an argument nor in the entry map).

public void addMultiValueAttribute (String dn, String attributeName, List<Object> attributeValues)

Adds all the values for an attribute in an existing LDAP entry. If the entry already contained a value (or values) for the given attributeName then these values will be added. The attribute should allow multiple values or an exception will be raised.

Parameters
dn The DN of the LDAP entry to modify
attributeName The name of the attribute to add values to.
attributeValues The values for the attribute
Throws
NoPermissionException If the current binded user has no permissions to update the entry.
NameNotFoundException If there is no existing entry for the given DN.
InvalidAttributeException If the attribute value is invalid or the entry already has the provided value.
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error updating the entry.

public void addSingleValueAttribute (String dn, String attributeName, String attributeValue)

Adds a value for an attribute in an existing LDAP entry. If the entry already contained a value for the given attributeName then this value will be added (only if the attribute is multi value and there entry didn't have the value already).

If you want to add a value with a type different than String, then you can use the add-multi-value-attribute operation and define a one element list with the value.

Parameters
dn The DN of the LDAP entry to modify
attributeName The name of the attribute to add a value to.
attributeValue The value for the attribute
Throws
NoPermissionException If the current binded user has no permissions to update the entry.
InvalidAttributeException If the attribute value is invalid or the entry already has the provided value.
NameNotFoundException If there is no existing entry for the given DN.
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error updating the entry.

public LDAPEntry bind ()

Performs an LDAP bind (login) operation. After login there will be a LDAP connection pool ready to use for other operations using the authenticated user. If no values are provided to override authDn and authPassword then using this operation will just re-bind (re-authenticate) the user/password defined in the config element. If new values are provided for authDn and authPassword, then authentication will be performed.

Re-authenticating and returning the LDAP entry using config level credentials (authDn & authPassword)

Authenticating and returning the LDAP entry using new credentials (authDn & authPassword)

Authenticating as anonymous user (returns always null)

Authenticating and returning the LDAP entry using credentials (authDn & authPassword) from Mule Expression

Returns
Throws
NoPermissionException If the current binded user has no permissions to perform the lookup for its own LDAP entry.
NameNotFoundException If base DN is invalid (for example it doesn't exist)
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error performing the login and posterior lookup.

public void connect (String authDn, String authPassword, String authentication)

Establish the connection to the LDAP server and use connection management to handle different users.

Parameters
authDn The DN (distinguished name) of the user (for example: uid=user,ou=people,dc=mulesoft,dc=org). If using Microsoft Active Directory, instead of the DN, you can provide the user@domain (for example: user@mulesoft.org)
authPassword The password of the user
authentication Specifies the authentication mechanism to use. For the Sun LDAP service provider, this can be one of the following strings:
  • simple (DEFAULT): Used for user/password authentication.
  • none: Used for anonymous authentication.
  • sasl_mech (UNSUPPORTED): Where sasl_mech is a space-separated list of SASL mechanism names. SASL is the Simple Authentication and Security Layer (RFC 2222). It specifies a challenge-response protocol in which data is exchanged between the client and the server for the purposes of authentication and establishment of a security layer on which to carry out subsequent communication. By using SASL, the LDAP can support any type of authentication agreed upon by the LDAP client and server.
Throws
ConnectionException Holding one of the possible values in ConnectionExceptionCode.

public String connectionId ()

Returns the connection ID

Returns
  • String with the connection Id

public void delete (String dn)

Deletes the LDAP entry represented by the provided distinguished name. The entry should not have child entries, in which case a ContextNotEmptyException is thrown.

This operation is idempotent. It succeeds even if the terminal atomic name is not bound in the target context, but throws NameNotFoundException if any of the intermediate contexts do not exist.

Parameters
dn The DN of the LDAP entry to delete
Throws
NoPermissionException If the current binded user has no permissions to delete the entry.
NameNotFoundException If an intermediate context does not exist.
ContextNotEmptyException If the entry to delete has child entries.
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error deleting the entry.

public void deleteMultiValueAttribute (String dn, String attributeName, List<Object> attributeValues)

Deletes all the values matching attributeValues of the attribute defined by attributeName. Values that are not present in the entry are ignored. If no values are specified, then the whole attribute is deleted from the entry.

Parameters
dn The DN of the LDAP entry to modify
attributeName The name of the attribute to delete its values.
attributeValues The values that should be deleted.
Throws
NoPermissionException If the current binded user has no permissions to update the entry.
NameNotFoundException If there is no existing entry for the given DN.
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error updating the entry.

public void deleteSingleValueAttribute (String dn, String attributeName, String attributeValue)

Deletes the value matching attributeValue of the attribute defined by attributeName. If the entry didn't have the value, then the entry stays the same. If no value is specified, then the whole attribute is deleted from the entry.

If you want to delete a value with a type different than String, then you can use the delete-multi-value-attribute operation and define a one element list with the value.

Parameters
dn The DN of the LDAP entry to modify
attributeName The name of the attribute to delete its value.
attributeValue The value that should be deleted.
Throws
NoPermissionException If the current binded user has no permissions to update the entry.
NameNotFoundException If there is no existing entry for the given DN.
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error updating the entry.

public void disconnect ()

Disconnect the current connection

public Map<String, String> getExtendedConfiguration ()

public int getInitialPoolSize ()

public int getMaxPoolSize ()

public long getPoolTimeout ()

public Referral getReferral ()

public Type getType ()

public String getUrl ()

public boolean isConnected ()

Are we connected?

Returns
  • boolean true if the connection is still valid or false otherwise.

public static String ldapEntryToLdif (LDAPEntry entry)

Transforms a LDAPEntry to a String in LDIF representation (RFC 2849).

Parameters
entry The LDAPEntry to transform to LDIF.
Returns
  • The LDIF representation of the entry.

public static Map<String, Object> ldapEntryToMap (LDAPEntry entry)

Creates the Map representation of an LDAPEntry.

The resulting map has the name of the attributes as String keys and the values for these keys are:

  • Distinguished name: The DN is the value of the special string key "dn" (see MAP_DN_KEY).
  • Single Value Attributes: The value is an Object (most of the cases a String and in some cases, like userPassword, a byte[]).
  • Multi-value Attributes: The value is a List containing all the values for the attribute (most of the cases a String and in some cases, like userPassword, a byte[]).

Parameters
entry The LDAPEntry to transform to map.
Returns
  • The Map representation of the entry.

public LDAPEntry lookup (String dn, List<String> attributes)

Retrieves an entry from the LDAP server base on its distinguished name (DN). DNs are the unique identifiers of an LDAP entry, so this method will perform a search based on this ID and so return a single entry as result or throw an exception if the DN is invalid or inexistent.

Use this operation over searchOne(String, String, List, SearchScope, int, long, boolean) when you know the DN of the object you want to retrieve.

Lookup returning all attributes for the entry

Lookup returning the attributes in the list obtained by expression

Lookup returning the attributes defined in the XML config file

Parameters
dn The DN of the LDAP entry that will be retrieved.
attributes A list of the attributes that should be returned in the result. If the attributes list is empty or null, then by default all LDAP entry attributes are returned.
Returns
Throws
NoPermissionException If the current binded user has no permissions to perform the lookup for the given DN.
NameNotFoundException If base DN is invalid (for example it doesn't exist)
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error performing the search.

public static LDAPEntry mapToLdapEntry (Map<String, Object> entry)

Creates a LDAPEntry from its Map representation. This transformer won't check that the entry is valid. The only validation that is performed is the presence of the distinguished name.

In order to represent a LDAP entry as a map, you should consider the following rules for the map key/value pair:

  • Distinguished name: The map should have a special attribute for the distinguish name. In this case, the key should be the string "dn" (see MAP_DN_KEY) and the value a String representing the distinguished name (for example cn=andy,ou=people,dc=mulesoft,dc=org).
  • Single Value Attributes: The key should be the name of the single value attribute (for example uid, cn, ...) as a String and the value is just the value of the attribute (most of the times represented by a String.
  • Multi-value Attributes: The key should be the name of the multiple values attribute (for example objectClass, memberOf, mail, ...) as a String and the value should be a List holding the multiple values of the attribute. Usually it will be a list of strings.

Parameters
entry Map representation of the LDAP entry.
Returns
Throws
Exception If the map entry is invalid (for example, it doesn't contain the DN)

public void modify (LDAPEntry entry)

Updates an existing LDAPEntry in the LDAP server. The entry should contain an existing distinguished name (DN), the objectClass attributes that define its structure and at least a value for all the required attributes (required attributes depend on the object classes assigned to the entry. You can refer to RFC 4519 for standard object classes and attributes.

When updating a LDAP entry, only the attributes in the entry passed as parameter are updated or added. If you need to delete an attribute, you should use the delete attribute operation.

Example: Updating one attributes and adding one.

Original LDAP server entry:
dn: cn=entry,ou=group,dc=company,dc=org
cn: entry
attr1: Value1
attr2: Value2
multi1: Value3
multi1: Value4
objectclass: top
objectclass: myentry


Entry map passed as parameter:
dn: cn=entry,ou=group,dc=company,dc=org
attr1: NewValue
attr3: NewAttributeValue


Resulting LDAP server entry:
dn: cn=entry,ou=group,dc=company,dc=org
cn: entry
attr1: NewValue
attr2: Value2
multi1: Value3
multi1: Value4
attr3: NewAttributeValue
objectclass: top
objectclass: myentry

The LDAP entry is in the payload

The LDAP entry is in a session variable

Parameters
entry The LDAPEntry that should be updated.
Throws
NoPermissionException If the current binded user has no permissions to update entries under any of the RDN (relative DN) that compose the entry DN.
InvalidAttributeException If the structure of the entry is invalid (for example there are missing required attributes or it has attributes that are not part of any of the defined object classes)
NameNotFoundException If there is no existing entry with the same DN in the LDAP server tree.
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error updating the entry.

public void modifyFromMap (String dn, Map<String, Object> entry)

Updates an existing entry in the LDAP server from a Map representation. The distinguished name (DN) of the entry is first obtained from the optional parameter dn and if this value is blank (null, empty string or string with only space chars) then the DN should be a present in the entry map as a String value under the key "dn" (see MAP_DN_KEY).

When updating a LDAP entry, only the attributes in the entry passed as parameter are updated or added. If you need to delete an attribute, you should use the delete attribute operation.

Example: Updating one attributes and adding one.

Original LDAP server entry:
dn: cn=entry,ou=group,dc=company,dc=org
cn: entry
attr1: Value1
attr2: Value2
multi1: Value3
multi1: Value4
objectclass: top
objectclass: myentry


Entry map passed as parameter:
dn: cn=entry,ou=group,dc=company,dc=org
attr1: NewValue
attr3: NewAttributeValue


Resulting LDAP server entry:
dn: cn=entry,ou=group,dc=company,dc=org
cn: entry
attr1: NewValue
attr2: Value2
multi1: Value3
multi1: Value4
attr3: NewAttributeValue
objectclass: top
objectclass: myentry

In order to represent a LDAP entry as a map, you should consider the following rules for the map key/value pair:

  • Single Value Attributes: The key should be the name of the single value attribute (for example uid, cn, ...) as a String and the value is just the value of the attribute (most of the times represented by a String.
  • Multi-value Attributes: The key should be the name of the multiple values attribute (for example objectClass, memberOf, mail, ...) as a String and the value should be a List holding the multiple values of the attribute. Usually it will be a list of strings.
  • Distinguished name: As an alternative to passing the DN as a separate argument of the operation, you can include it in the entry map. In this case, the key should be the string "dn" (see MAP_DN_KEY) and the value a String representing the distinguished name (for example cn=andy,ou=people,dc=mulesoft,dc=org).

The map is provided as a reference and the DN is not in the map

The map is created in the XML file and the DN is another map entry

The map is provided in the payload and the DN is another map entry

Parameters
dn The primary value to use as DN of the entry. If not set, then the DN will be retrieved from the map representing the entry under the key dn.
entry Map representation of the LDAP entry.
Throws
NoPermissionException If the current binded user has no permissions to update entries under any of the RDN (relative DN) that compose the entry DN.
InvalidAttributeException If the structure of the entry is invalid (for example there are missing required attributes or it has attributes that are not part of any of the defined object classes)
NameNotFoundException If there is no existing entry with the same DN in the LDAP server tree.
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error updating the entry (for example if the DN is not passed as an argument nor in the entry map).

public void modifyMultiValueAttribute (String dn, String attributeName, List<Object> attributeValues)

Updates (replaces) the value or values of the attribute defined by attributeName with the new values defined by attributeValues. If the attribute was not present in the entry, then the value is added.

Parameters
dn The DN of the LDAP entry to modify
attributeName The name of the attribute to update its values.
attributeValues The new values for the attribute
Throws
NoPermissionException If the current binded user has no permissions to update the entry.
NameNotFoundException If there is no existing entry for the given DN.
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error updating the entry.

public void modifySingleValueAttribute (String dn, String attributeName, String attributeValue)

Updates (replaces) the value or values of the attribute defined by attributeName with the new value defined by attributeValue. If the attribute was not present in the entry, then the value is added.

If you want to update a value with a type different than String, then you can use the update-multi-value-attribute operation and define a one element list with the value.

Parameters
dn The DN of the LDAP entry to modify
attributeName The name of the attribute to update its value.
attributeValue The new value for the attribute
Throws
NoPermissionException If the current binded user has no permissions to update the entry.
NameNotFoundException If there is no existing entry for the given DN.
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error updating the entry.

public List<Object> pagedResultSearch (String baseDn, String filter, List<String> attributes, SearchScope scope, int timeout, long maxResults, boolean returnObject, int pageSize, int resultPageSize, SourceCallback callback)

Performs a LDAP search and streams result to the rest of the flow. This means that instead of returning a list with all results it partitions the LDAP search result into pages (individual entry if resultPageSize is 1) or lists of size resultPageSize.

For queries returning large results it is recommended to use pagination (not all LDAP servers support this or are configured to support it). For that you need to provide a page size value that should be less or equal than max results (count limit). If you are getting a Size Limit Exceeded exception message then you should check that the authenticated user has enough privileges or the LDAP server is not limited by configuration.

Returning all persons one LDAP entry at a time

Returning all persons in lists of 100 LDAP entries

Parameters
baseDn The base DN of the LDAP search.
filter A valid LDAP filter. The LDAP connector supports LDAP search filters as defined in RFC 2254. Some examples are:
  • (objectClass=*): All objects.
  • (&(objectClass=person)(!cn=andy)): All persons except for the one with common name (cn) "andy".
  • (sn=sm*): All objects with a surname that starts with "sm".
  • (&(objectClass=person)(|(sn=Smith)(sn=Johnson))): All persons with a surname equal to "Smith" or "Johnson".
attributes A list of the attributes that should be returned in the result. If the attributes list is empty or null, then by default all LDAP entry attributes are returned.
scope The scope of the search. Valid attributes are:
  • OBJECT: This value is used to indicate searching only the entry at the base DN, resulting in only that entry being returned (keeping in mind that it also has to meet the search filter criteria!)
  • ONE_LEVEL: This value is used to indicate searching all entries one level under the base DN - but not including the base DN and not including any entries under that one level under the base DN.
  • SUB_TREE: This value is used to indicate searching of all entries at all levels under and including the specified base DN.
timeout Search timeout in milliseconds. If the value is 0, this means to wait indefinitely.
maxResults The maximum number of entries that will be returned as a result of the search. 0 indicates that all entries will be returned.
returnObject Enables/disables returning objects returned as part of the result. If disabled, only the name and class of the object is returned. If enabled, the object will be returned.
pageSize If the LDAP server supports paging results set in this attribute the size of the page. If the pageSize is less or equals than 0, then paging will be disabled.
resultPageSize The size of the list this operation streams. If this value is less than 1, then it will be considered that the page size is 1.
callback Used to stream results
Returns
  • A list with individual results of executing the rest of flow with each results page.
Throws
NoPermissionException If the current binded user has no permissions to perform the search under the given base DN.
NameNotFoundException If base DN is invalid (for example it doesn't exist)
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error performing the search.

public void rename (String oldDn, String newDn)

Renames and existing LDAP entry (moves and entry from a DN to another one).

Parameters
oldDn DN of the existing entry that will be renamed.
newDn Destination DN
Throws
NameAlreadyBoundException If there is already an existing entry with the same DN as newDn.
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error deleting the entry.

public List<LDAPEntry> search (String baseDn, String filter, List<String> attributes, SearchScope scope, int timeout, long maxResults, boolean returnObject, int pageSize)

Performs a LDAP search returning a list with all the resulting LDAP entries.

For queries returning large results it is recommended to use pagination (not all LDAP servers support this or are configured to support it). For that you need to provide a page size value that should be less or equal than max results (count limit). If you are getting a Sizelimit Exceeded exception then you should check that the authenticated user has enough privileges or the LDAP server is not limited by configuration.

Returning all attributes for all persons that have Doe as surname

Returning username and fullname for the first 100 person entries

Search that receives all configuration attributes using Mule Expressions

Parameters
baseDn The base DN of the LDAP search.
filter A valid LDAP filter. The LDAP connector supports LDAP search filters as defined in RFC 2254. Some examples are:
  • (objectClass=*): All objects.
  • (&(objectClass=person)(!cn=andy)): All persons except for the one with common name (cn) "andy".
  • (sn=sm*): All objects with a surname that starts with "sm".
  • (&(objectClass=person)(|(sn=Smith)(sn=Johnson))): All persons with a surname equal to "Smith" or "Johnson".
attributes A list of the attributes that should be returned in the result. If the attributes list is empty or null, then by default all LDAP entry attributes are returned.
scope The scope of the search. Valid attributes are:
  • OBJECT: This value is used to indicate searching only the entry at the base DN, resulting in only that entry being returned (keeping in mind that it also has to meet the search filter criteria!)
  • ONE_LEVEL: This value is used to indicate searching all entries one level under the base DN - but not including the base DN and not including any entries under that one level under the base DN.
  • SUB_TREE: This value is used to indicate searching of all entries at all levels under and including the specified base DN.
timeout Search timeout in milliseconds. If the value is 0, this means to wait indefinitely.
maxResults The maximum number of entries that will be returned as a result of the search. 0 indicates that all entries will be returned.
returnObject Enables/disables returning objects returned as part of the result. If disabled, only the name and class of the object is returned. If enabled, the object will be returned.
pageSize If the LDAP server supports paging results set in this attribute the size of the page. If the pageSize is less or equals than 0, then paging will be disabled.
Returns
  • A java.util.List of LDAPEntry objects with the results of the search. If the search throws no results, then this is an empty list.
Throws
NoPermissionException If the current binded user has no permissions to perform the search under the given base DN.
NameNotFoundException If base DN is invalid (for example it doesn't exist)
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error performing the search.

public LDAPEntry searchOne (String baseDn, String filter, List<String> attributes, SearchScope scope, int timeout, long maxResults, boolean returnObject)

Performs a LDAP search that is supposed to return a unique result. If the search returns more than one result, then a warn log message is generated and the first element of the result is returned.

Use this operation over lookup(String, List) when you know don't know the DN of the entry you need to retrieve but you have a set of attributes that you know should return a single entry (for example an email address)

Parameters
baseDn The base DN of the LDAP search.
filter A valid LDAP filter. The LDAP connector supports LDAP search filters as defined in RFC 2254. Some examples are:
  • (objectClass=*): All objects.
  • (&(objectClass=person)(!cn=andy)): All persons except for the one with common name (cn) "andy".
  • (sn=sm*): All objects with a surname that starts with "sm".
  • (&(objectClass=person)(|(sn=Smith)(sn=Johnson))): All persons with a surname equal to "Smith" or "Johnson".
attributes A list of the attributes that should be returned in the result. If the attributes list is empty or null, then by default all LDAP entry attributes are returned.
scope The scope of the search. Valid attributes are:
  • OBJECT: This value is used to indicate searching only the entry at the base DN, resulting in only that entry being returned (keeping in mind that it also has to meet the search filter criteria!)
  • ONE_LEVEL: This value is used to indicate searching all entries one level under the base DN - but not including the base DN and not including any entries under that one level under the base DN.
  • SUB_TREE: This value is used to indicate searching of all entries at all levels under and including the specified base DN.
timeout Search timeout in milliseconds. If the value is 0, this means to wait indefinitely.
maxResults The maximum number of entries that will be returned as a result of the search. 0 indicates that all entries will be returned.
returnObject Enables/disables returning objects returned as part of the result. If disabled, only the name and class of the object is returned. If enabled, the object will be returned.
Returns
  • A LDAPEntry with the first element of the search result or null if there are no results.
Throws
NoPermissionException If the current binded user has no permissions to perform the search under the given base DN.
NameNotFoundException If base DN is invalid (for example it doesn't exist)
LDAPException In case there is any other exception, mainly related to connectivity problems or referrals.
Exception In case there is any other error performing the search.

public void setExtendedConfiguration (Map<String, String> extendedConfiguration)

Parameters
extendedConfiguration

public void setInitialPoolSize (int initialPoolSize)

Parameters
initialPoolSize

public void setMaxPoolSize (int maxPoolSize)

Parameters
maxPoolSize

public void setPoolTimeout (long poolTimeout)

Parameters
poolTimeout

public void setReferral (Referral referral)

Parameters
referral

public void setType (Type type)

Parameters
type

public void setUrl (String url)

Parameters
url