Package org.frankframework.ldap
Class LdapSender
java.lang.Object
org.frankframework.jndi.JndiBase
org.frankframework.ldap.LdapSender
- All Implemented Interfaces:
FrankElement,HasApplicationContext,HasName,IConfigurable,IScopeProvider,ISender,ISenderWithParameters,IWithParameters,NameAware,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
Sender to obtain information from and write to an LDAP Directory.
Returns the set of attributes in an XML format. Examples are shown below.
This may result in the following output:
Search or Read? Read retrieves all the attributes of the specified entry. Search retrieves all the entries of the specified (by entryName) context that have the specified attributes, together with the attributes. If the specified attributes are null or empty all the attributes of all the entries within the specified context are returned. Sample result of a
Sample result of a
example
Consider the following configuration example:
<sender
className="org.frankframework.ldap.LdapSender"
ldapProviderURL="ldap://servername:389/o=ing"
operation="read"
attributesToReturn="givenName,sn,telephoneNumber" >
<param name="entryName" xpathExpression="entryName" />
</sender>
This may result in the following output:
<ldap>
<entryName>uid=srp,ou=people</entryName>
<attributes>
<attribute attrID="givenName">
<value>Jan</value>
</attribute>
<attribute attrID="telephoneNumber">
<value>010 5131123</value>
<value>06 23456064</value>
</attribute>
<attribute attrID="sn">
<value>Jansen</value>
</attribute>
</attributes>
</ldap>
Search or Read? Read retrieves all the attributes of the specified entry. Search retrieves all the entries of the specified (by entryName) context that have the specified attributes, together with the attributes. If the specified attributes are null or empty all the attributes of all the entries within the specified context are returned. Sample result of a
read operation:
<attributes>
<attribute>
<attribute name="employeeType" value="Extern"/>
<attribute name="roomNumber" value="DP 2.13.025"/>
<attribute name="departmentCode" value="358000"/>
<attribute name="organizationalHierarchy">
<item value="ou=ING-EUR,ou=Group,ou=Organization,o=ing"/>
<item value="ou=OPS&IT,ou=NL,ou=ING-EUR,ou=Group,ou=Organization,o=ing"/>
<item value="ou=000001,ou=OPS&IT,ou=NL,ou=ING-EUR,ou=Group,ou=Organization,o=ing"/>
</attribute>
<attribute name="givenName" value="Gerrit"/>
</attributes>
Sample result of a
search operation:
<entries>
<entry name="uid=srp">
<attributes>
<attribute>
<attribute name="employeeType" value="Extern"/>
<attribute name="roomNumber" value="DP 2.13.025"/>
<attribute name="departmentCode" value="358000"/>
<attribute name="organizationalHierarchy">
<item value="ou=ING-EUR,ou=Group,ou=Organization,o=ing"/>
<item value="ou=OPS&IT,ou=NL,ou=ING-EUR,ou=Group,ou=Organization,o=ing"/>
<item value="ou=000001,ou=OPS&IT,ou=NL,ou=ING-EUR,ou=Group,ou=Organization,o=ing"/>
</attribute>
<attribute name="givenName" value="Gerrit"/>
</attributes>
</entry>
<entry> .... </entry>
.....
</entries>
- Author:
- Gerrit van Brakel, Jaco de Groot
- Specific parameters
- entryName Represents entryName (RDN) of interest., filterExpression Filter expression (handy with searching - see RFC2254)., principal Will overwrite jndiAuthAlias, principal and credential attributes together with parameter credentials which is expected to be present too. This will also have the effect of usePooling being set to false and the LDAP connection being made at runtime only (skipped at configuration time)., credentials See parameter principal. It's advised to set attribute hidden to true for parameter credentials.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enum -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected XmlBuilderattributesToXml(Attributes atts) protected voidcloseDirContext(DirContext dirContext) voidConfigure this component.protected DirContextgetDirContext(Map<String, String> paramValueMap) String[]getSubContextList(DirContext parentContext, String relativeContext, PipeLineSession session) Return a list of all of the subcontexts of the current context, which is relative to parentContext.booleanWhentrue, the result of sendMessage is the reply of the request.protected DirContextloopkupDirContext(Map<String, String> paramValueMap) Retrieves the DirContext from the JNDI environment and sets theproviderURLback toldapProviderURLif specified.performOperation(Message message, PipeLineSession session) Performs the specified operation and returns the results.protected AttributesStrips all the values from the attributes ininput.sendMessage(Message message, PipeLineSession session) Send a message to some destination (as configured in the Sender object).voidsetAttributesToReturn(String string) Comma separated list of attributes to return.voidsetErrorSessionKey(String string) Key of session variable used to store cause of errorsvoidsetJmsRealm(String jmsRealmName) Deprecated, for removal: This API element is subject to removal in a future version.voidsetLdapProviderURL(String string) URL to context to search in, e.g.voidSpecifies subject to perform operation on.voidsetMaxEntriesReturned(int i) The maximum number of entries to be returned by a search query, or0for unlimitedvoidname of the sendervoidsetOperation(LdapSender.Operation value) Specifies LDAP operation to performvoidsetProviderURL(String value) Deprecated, for removal: This API element is subject to removal in a future version.voidsetReplyNotFound(boolean b) (Only used whenoperation=search/deepsearch) whentruethe xml '<ldapresult>object not found</ldapresult>' is returned instead of the PartialResultException 'unprocessed continuation reference(s)'voidsetSearchTimeout(int i) Specifies the time (in ms) that is spent searching for results for operation searchvoidsetUnicodePwd(boolean b) Whentruethe attributes passed by the input xml are scanned for an attribute with id unicodepwd, when found the value of this attribute will be encoded as required by active directory (a UTF-16 encoded unicode string containing the password surrounded by quotation marks) before sending it to the LDAP servervoidsetUsePooling(boolean b) Specifies whether connection pooling is used or notvoidstart()This method will be called to start the sender.voidstop()Stop/close the sender and deallocate resources.voidstoreLdapException(Throwable t, PipeLineSession session) Methods inherited from class org.frankframework.jndi.JndiBase
getContext, getJndiEnv, setAuthentication, setCredentials, setInitialContextFactoryName, setJndiAuthAlias, setJndiProperties, setPrincipal, setSecurityProtocol, setUrlPkgPrefixes, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoaderMethods inherited from interface org.frankframework.core.ISender
sendMessageOrThrowMethods inherited from interface org.frankframework.core.ISenderWithParameters
consumesSessionVariable
-
Field Details
-
LDAP_ERROR_MAGIC_STRING
- See Also:
-
operation
-
paramList
-
-
Constructor Details
-
LdapSender
public LdapSender()
-
-
Method Details
-
configure
Description copied from interface:IConfigurableConfigure this component.configure()is called once at startup of the framework in the configure method of the owner of thisIConfigurable. Purpose of this method is to check whether the static configuration of the object is correct. As much as possible class-instantiating should take place in theconfigure(), to improve performance.In the case of a container, this will propagate the configure signal to all components that apply.
- Specified by:
configurein interfaceIConfigurable- Throws:
ConfigurationException- in case it was not able to configure the component.
-
storeLdapException
-
start
public void start()Description copied from interface:ISenderThis method will be called to start the sender. After this method is called the sendMessage method may be called. Purpose of this method is to reduce creating connections to databases etc. in thesendMessage()method. -
stop
public void stop()Description copied from interface:ISenderStop/close the sender and deallocate resources. -
isSynchronous
public boolean isSynchronous()Description copied from interface:ISenderWhentrue, the result of sendMessage is the reply of the request.- Specified by:
isSynchronousin interfaceISender
-
performOperation
public String performOperation(Message message, PipeLineSession session) throws SenderException, ParameterException Performs the specified operation and returns the results.- Returns:
- - Depending on operation, DEFAULT_RESULT or read/search result (always XML)
- Throws:
SenderExceptionParameterException
-
getSubContextList
public String[] getSubContextList(DirContext parentContext, String relativeContext, PipeLineSession session) Return a list of all of the subcontexts of the current context, which is relative to parentContext.- Returns:
- an array of Strings containing a list of the subcontexts for a current context.
-
sendMessage
@Nonnull public SenderResult sendMessage(@Nonnull Message message, @Nonnull PipeLineSession session) throws SenderException, TimeoutException Description copied from interface:ISenderSend a message to some destination (as configured in the Sender object). This method may only be called after theconfigure()method is called.The following table shows the difference between synchronous and a-synchronous senders:
synchronous a-synchronous ISender.isSynchronous()returnstruefalsereturn value of sendMessage()isthe reply-message the messageId of the message sent the correlationID specified with sendMessage()may be ignored is sent with the message a {link TimeOutException} may be thrown if a timeout occurs waiting for a reply should not be expected Multiple objects may try to call this method at the same time, from different threads. Implementations of this method should therefore be thread-safe, or
synchronized.- Specified by:
sendMessagein interfaceISender- Throws:
SenderExceptionTimeoutException
-
removeValuesFromAttributes
Strips all the values from the attributes ininput. This is performed to be able to delete the attributes without having to match the values. If values exist they must be exactly matched too in order to delete the attribute. -
loopkupDirContext
Retrieves the DirContext from the JNDI environment and sets theproviderURLback toldapProviderURLif specified.- Throws:
NamingException
-
getDirContext
- Throws:
SenderException
-
closeDirContext
-
attributesToXml
- Throws:
NamingException
-
addParameter
- Specified by:
addParameterin interfaceIWithParameters
-
getParameterList
- Specified by:
getParameterListin interfaceIWithParameters
-
setOperation
Specifies LDAP operation to perform- Default value
- read
-
setLdapProviderURL
URL to context to search in, e.g. 'ldap://edsnlm01.group.intranet/ou=people, o=ing' to search in te people group of ing cds. Used to overwrite the providerURL specified in jmsRealm. -
setProviderURL
@Deprecated(forRemoval=true, since="9.2.0") @ConfigurationWarning("JNDI usage is being deprecated, please use [ldapProviderURL] instead") public void setProviderURL(String value) Deprecated, for removal: This API element is subject to removal in a future version.Description copied from class:JndiBaseSets the value of providerURL- Overrides:
setProviderURLin classJndiBase
-
setManipulationSubject
Specifies subject to perform operation on.- Default value
- attribute
-
setAttributesToReturn
Comma separated list of attributes to return. When no are attributes specified, all the attributes from the object read are returned.- Default value
- all attributes
-
setUsePooling
public void setUsePooling(boolean b) Specifies whether connection pooling is used or not- Default value
- true when principal not set as parameter, false otherwise
-
setSearchTimeout
public void setSearchTimeout(int i) Specifies the time (in ms) that is spent searching for results for operation search- Default value
- 20000
-
setErrorSessionKey
Key of session variable used to store cause of errors- Default value
- errorReason
-
setMaxEntriesReturned
public void setMaxEntriesReturned(int i) The maximum number of entries to be returned by a search query, or0for unlimited- Default value
- 0
-
setUnicodePwd
public void setUnicodePwd(boolean b) Whentruethe attributes passed by the input xml are scanned for an attribute with id unicodepwd, when found the value of this attribute will be encoded as required by active directory (a UTF-16 encoded unicode string containing the password surrounded by quotation marks) before sending it to the LDAP server- Default value
- false
-
setReplyNotFound
public void setReplyNotFound(boolean b) (Only used whenoperation=search/deepsearch) whentruethe xml '<ldapresult>object not found</ldapresult>' is returned instead of the PartialResultException 'unprocessed continuation reference(s)'- Default value
- false
-
setJmsRealm
@Deprecated(forRemoval=true, since="9.2.0") @ConfigurationWarning("JNDI usage through a JmsRealm is discouraged!") public void setJmsRealm(String jmsRealmName) Deprecated, for removal: This API element is subject to removal in a future version.Description copied from class:JndiBaseloads JNDI (and other) properties from a JmsRealm- Overrides:
setJmsRealmin classJndiBase- See Also:
-
setName
name of the sender
-