@RequiresEnterpriseLicense(allowEval=true) @Connector(name="ldap", schemaVersion="3.5", friendlyName="LDAP", description="LDAP Connector that allows you to connect to any LDAP server and perform every LDAP operation") @ReconnectOn(exceptions=CommunicationException.class) @MetaDataScope(value=MetadataResolver.class) public class LDAPConnector extends Object
URL |
The connection URL to the LDAP server. LDAP connection URLs have the following syntax: ldap[s]://hostname:port/base_dn
|
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
|
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:
|
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:
|
Use Schema |
If set to true, the LDAP connector will use the LDAP schema (only works for LDAP v3) to define the structure of the LDAP entry (or map). This needs to be 'true' in order to use
DataSense. If useSchema is true, then the LDAP server schema will be used to determine if attributes of the LDAPEntry will be Multi Valued (LDAPMultiValueEntryAttribute ) or
Single Value LDAPSingleValueEntryAttribute . This translates if the value will be a List or a single Object (String, byte[], etc.). In the past,
attributes were Multi Valued only when the retrieved LDAP entry had more than one value. Example: Sample LDAP server entry:
dn: attr1=Value2,ou=group,dc=company,dc=org Schema for objectClass myentry:
attr1: {SINGLE-VALUE=true} If useSchema is false then the resulting LDAPEntry representing the payload will return:
// Using LDAPEntry methods If useSchema is true then the resulting LDAPEntry representing the payload will return:
// Using LDAPEntry methods |
Constructor and Description |
---|
LDAPConnector() |
Modifier and Type | Method and Description |
---|---|
void |
add(Map<String,Object> entry,
String structuralObjectClass)
Creates a new
LDAPEntry in the LDAP server. |
void |
addMultiValueAttribute(String dn,
String attributeName,
List<Object> attributeValues,
boolean ignoreInvalidAttribute)
Adds all the values for an attribute in an existing LDAP entry.
|
void |
addSingleValueAttribute(String dn,
String attributeName,
String attributeValue,
boolean ignoreInvalidAttribute)
Adds a value for an attribute in an existing LDAP entry.
|
LDAPEntry |
bind(String authDn,
String authPassword,
String authentication)
Performs an LDAP bind (login) operation.
|
void |
delete(String dn)
Deletes the LDAP entry represented by the provided distinguished name.
|
void |
deleteMultiValueAttribute(String dn,
String attributeName,
List<Object> attributeValues,
boolean ignoreInvalidAttribute)
Deletes all the values matching attributeValues of the attribute defined by attributeName.
|
void |
deleteSingleValueAttribute(String dn,
String attributeName,
String attributeValue,
boolean ignoreInvalidAttribute)
Deletes the value matching attributeValue of the attribute defined by attributeName.
|
boolean |
exists(String dn)
Checks whether a LDAP entry exists in the LDAP server or not.
|
AbstractConfig |
getConfig() |
String |
ldapEntryToLdif(LDAPEntry entry)
|
LDAPEntry |
lookup(String dn,
List<String> attributes,
String structuralObjectClass)
Retrieves an entry from the LDAP server base on its distinguished name (DN).
|
void |
modify(LDAPEntry entry,
String structuralObjectClass)
Updates an existing
LDAPEntry in the LDAP server. |
void |
modifyMultiValueAttribute(String dn,
String attributeName,
List<Object> attributeValues,
boolean ignoreInvalidAttribute)
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,
boolean ignoreInvalidAttribute)
Updates (replaces) the value or values of the attribute defined by attributeName with the new value defined by attributeValue.
|
org.mule.streaming.ProviderAwarePagingDelegate<LDAPEntry,LDAPConnector> |
pagedResultSearch(String baseDn,
String filter,
List<String> attributes,
SearchScope scope,
int timeout,
long maxResults,
boolean returnObject,
int pageSize,
String orderBy,
boolean ascending,
String structuralObjectClass,
org.mule.streaming.PagingConfiguration pagingConfiguration)
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,
String structuralObjectClass)
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,
String structuralObjectClass)
Performs a LDAP search that is supposed to return a unique result.
|
void |
setConfig(AbstractConfig config) |
void |
unbind(Boolean force)
Closes the current connection, forcing the login operation (bind) the next time it is used.
|
public AbstractConfig getConfig()
public void setConfig(@NotNull AbstractConfig config)
@Processor public LDAPEntry bind(@FriendlyName(value="Principal DN")@Optional String authDn, @FriendlyName(value="Password")@Password@Optional String authPassword, @Optional String authentication) throws Exception
LDAPEntry
of the authenticated user.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.@Processor public void unbind(@Default(value="false")@Optional Boolean force)
@Processor public LDAPEntry lookup(@FriendlyName(value="DN") String dn, @Optional List<String> attributes, @MetaDataKeyParam(affects=OUTPUT)@Optional String structuralObjectClass) throws Exception
searchOne(String, String, List, SearchScope, int, long, boolean, String)
when you know the DN of the object you want to retrieve.
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.structuralObjectClass
- The type of entry that will be returned. Only for DataSense purposes to be used in Anypoint Studio IDE. Has no impact on runtime, that's why it is optional.LDAPEntry
for the given dn
parameter.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 lookup.@Processor public boolean exists(@FriendlyName(value="DN") String dn) throws Exception
dn
- The DN of the LDAP entry that will be retrieved.dn
exists or false if notNoPermissionException
- If the current binded user has no permissions to perform the lookup for the given DN.LDAPException
- In case there is any other exception, mainly related to connectivity problems or referrals.NameNotFoundException
- Only in case throwException is true and the LDAP entry does not exist.Exception
- In case there is any other error checking for entry existence.@Processor public List<LDAPEntry> search(@FriendlyName(value="Base DN") String baseDn, String filter, @Optional List<String> attributes, @Default(value="ONE_LEVEL") SearchScope scope, @Placement(group="Search Controls")@Default(value="0") int timeout, @Placement(group="Search Controls")@Default(value="0") long maxResults, @Placement(group="Search Controls")@Default(value="false") boolean returnObject, @Placement(group="Search Controls")@Default(value="0") int pageSize, @MetaDataKeyParam(affects=OUTPUT)@Optional String structuralObjectClass) throws Exception
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:
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:
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.structuralObjectClass
- The type of entry that will be returned. Only for DataSense purposes to be used in Anypoint Studio IDE. Has no impact on runtime, that's why it is optional.List
of LDAPEntry
objects with the results of the search. If the search throws no results, then this is an empty list.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.@Processor @Paged(defaultFetchSize=200) public org.mule.streaming.ProviderAwarePagingDelegate<LDAPEntry,LDAPConnector> pagedResultSearch(@FriendlyName(value="Base DN") String baseDn, String filter, @Optional List<String> attributes, @Default(value="ONE_LEVEL") SearchScope scope, @Placement(group="Search Controls")@Default(value="0") int timeout, @Placement(group="Search Controls")@Default(value="0") long maxResults, @Placement(group="Search Controls")@Default(value="false") boolean returnObject, @Placement(group="Search Controls")@Default(value="0") int pageSize, @FriendlyName(value="Order by attribute")@Placement(group="Search Controls",order=1)@Optional String orderBy, @FriendlyName(value="Ascending order?")@Placement(group="Search Controls",order=2)@Default(value="true") boolean ascending, @MetaDataKeyParam(affects=OUTPUT)@Optional String structuralObjectClass, @RefOnly org.mule.streaming.PagingConfiguration pagingConfiguration) throws Exception
List
of resultPageSize size) the
rest of the flow will be executed. Each of these executions will return a result that will be aggregated into a List
of results.
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
fetch size (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. In that case, just reduce the value of the fetch size.
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:
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:
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.orderBy
- Name of the LDAP attribute used to sort results.ascending
- If orderBy was set, whether to sort in ascending or descending order.structuralObjectClass
- The type of entry that will be returned. Only for DataSense purposes to be used in Anypoint Studio IDE. Has no impact on runtime, that's why it is optional.pagingConfiguration
- Paging configuration. The field fetchSize in this object represents the size of pages Mule will use while iterating (vs pageSize that is an LDAP related attribute
used for the amount of LDAP entries retrieved at once while iterating at low level the LDAP results)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.@Processor public LDAPEntry searchOne(@FriendlyName(value="Base DN") String baseDn, String filter, @Optional List<String> attributes, @Default(value="ONE_LEVEL") SearchScope scope, @Placement(group="Search Controls")@Default(value="0") int timeout, @Placement(group="Search Controls")@Default(value="0") long maxResults, @Placement(group="Search Controls")@Default(value="false") boolean returnObject, @MetaDataKeyParam(affects=OUTPUT)@Optional String structuralObjectClass) throws Exception
lookup(String, List, String)
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)
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:
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:
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.structuralObjectClass
- The type of entry that will be returned. Only for DataSense purposes to be used in Anypoint Studio IDE. Has no impact on runtime, that's why it is optional.LDAPEntry
with the first element of the search result or null if there are no results.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.@Processor(friendlyName="Add entry") public void add(@RefOnly@Default(value="#[payload]") Map<String,Object> entry, @MetaDataKeyParam(affects=INPUT)@Optional String structuralObjectClass) throws Exception
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.
entry
- The LDAPEntry
that should be added.structuralObjectClass
- The type of entry that will be added. If the entry doesn't have the objectClass attribute set, then this one will be used to retrieved the whole objectClass
hierarchy. If performance is a requirement, don't rely on this functionality as several calls to the LDAP server will be done to trasverse the object class
hierarchy.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.@Processor(friendlyName="Modify entry") public void modify(@RefOnly@Default(value="#[payload]") LDAPEntry entry, @MetaDataKeyParam(affects=INPUT)@Optional String structuralObjectClass) throws Exception
LDAPEntry
in the LDAP server. The entry should contain an existing distinguished name (DN), 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.
dn: cn=entry,ou=group,dc=company,dc=org
cn: entry
attr1: Value1
attr2: Value2
multi1: Value3
multi1: Value4
objectclass: top
objectclass: myentry
dn: cn=entry,ou=group,dc=company,dc=org
attr1: NewValue
attr3: NewAttributeValue
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
entry
- The LDAPEntry
that should be updated.structuralObjectClass
- The type of entry that will be updated. Only for DataSense purposes to be used in Anypoint Studio IDE. Has no impact on runtime, that's why it is optional.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.@Processor(friendlyName="Delete entry") public void delete(@FriendlyName(value="DN")@Default(value="#[payload]") String dn) throws Exception
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.
dn
- The DN of the LDAP entry to deleteNoPermissionException
- 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.@Processor(friendlyName="Rename entry") public void rename(@Placement(order=1)@FriendlyName(value="Current DN") String oldDn, @Placement(order=2)@FriendlyName(value="New DN") String newDn) throws Exception
oldDn
- DN of the existing entry that will be renamed.newDn
- Destination DNNameAlreadyBoundException
- 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.@Processor public void addSingleValueAttribute(@FriendlyName(value="DN") String dn, String attributeName, String attributeValue, @Default(value="false") boolean ignoreInvalidAttribute) throws Exception
String
, then you can use the add-multi-value-attribute operation and define a one element list with the value.
dn
- The DN of the LDAP entry to modifyattributeName
- The name of the attribute to add a value to.attributeValue
- The value for the attributeignoreInvalidAttribute
- If the attribute value to add is already present, then don't throw InvalidAttributeException
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.InvalidAttributeException
- If the entry does have the attribute value that should be added. Ignored if ignoreInvalidAttribute is true. Note: Not every LDAP server will through this
exception.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.@Processor public void addMultiValueAttribute(@FriendlyName(value="DN") String dn, String attributeName, @RefOnly@Default(value="#[payload]") List<Object> attributeValues, @Default(value="false") boolean ignoreInvalidAttribute) throws Exception
dn
- The DN of the LDAP entry to modifyattributeName
- The name of the attribute to add values to.attributeValues
- The values for the attributeignoreInvalidAttribute
- If the attribute value to add is already present, then don't throw InvalidAttributeException
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.InvalidAttributeException
- If the entry does have the attribute value that should be added. Ignored if ignoreInvalidAttribute is true. Note: Not every LDAP server will through this
exception.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.@Processor public void modifySingleValueAttribute(@FriendlyName(value="DN") String dn, String attributeName, String attributeValue, @Default(value="false") boolean ignoreInvalidAttribute) throws Exception
String
, then you can use the update-multi-value-attribute operation and define a one element list with the
value.
dn
- The DN of the LDAP entry to modifyattributeName
- The name of the attribute to update its value.attributeValue
- The new value for the attributeignoreInvalidAttribute
- If the attribute value to modify is already present, then don't throw InvalidAttributeException
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 entry does have the attribute value that should be modified. Ignored if ignoreInvalidAttribute is true. Note: Not every LDAP server will through
this exception.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.@Processor public void modifyMultiValueAttribute(@FriendlyName(value="DN") String dn, String attributeName, @RefOnly List<Object> attributeValues, @Default(value="false") boolean ignoreInvalidAttribute) throws Exception
dn
- The DN of the LDAP entry to modifyattributeName
- The name of the attribute to update its values.attributeValues
- The new values for the attributeignoreInvalidAttribute
- If the attribute value to modify is already present, then don't throw InvalidAttributeException
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 entry does have the attribute value that should be modified. Ignored if ignoreInvalidAttribute is true. Note: Not every LDAP server will through
this exception.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.@Processor public void deleteSingleValueAttribute(@FriendlyName(value="DN") String dn, String attributeName, @Optional String attributeValue, @Default(value="false") boolean ignoreInvalidAttribute) throws Exception
String
, then you can use the delete-multi-value-attribute operation and define a one element list with the
value.
dn
- The DN of the LDAP entry to modifyattributeName
- The name of the attribute to delete its value.attributeValue
- The value that should be deleted.ignoreInvalidAttribute
- If the attribute or value to delete is no present, then don't throw InvalidAttributeException
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 entry doesn't have the attribute or value that should be deleted. Ignored if ignoreInvalidAttribute is true. Note: Not every LDAP server will
through this exception.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.@Processor public void deleteMultiValueAttribute(@FriendlyName(value="DN") String dn, String attributeName, @RefOnly@Optional List<Object> attributeValues, @Default(value="false") boolean ignoreInvalidAttribute) throws Exception
dn
- The DN of the LDAP entry to modifyattributeName
- The name of the attribute to delete its values.attributeValues
- The values that should be deleted.ignoreInvalidAttribute
- If the attribute or value to delete is no present, then don't throw InvalidAttributeException
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 entry doesn't have the attribute or value that should be deleted. Ignored if ignoreInvalidAttribute is true. Note: Not every LDAP server will
through this exception.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.Copyright © 2010–2018. All rights reserved.