public class LdapSender extends JndiBase implements ISenderWithParameters
<sender
className="nl.nn.adapterframework.ldap.LdapSender"
ldapProviderURL="ldap://servername:389/o=ing"
operation="read"
attributesToReturn="givenName,sn,telephoneNumber" >
<param name="entryName" xpathExpression="entryName" />
</sender>
<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>
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>
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>
Modifier and Type | Class and Description |
---|---|
static class |
LdapSender.Manipulation |
static class |
LdapSender.Operation |
Modifier and Type | Field and Description |
---|---|
static String |
LDAP_ERROR_MAGIC_STRING |
LdapSender.Operation |
operation |
protected ParameterList |
paramList |
Constructor and Description |
---|
LdapSender() |
Modifier and Type | Method and Description |
---|---|
void |
addParameter(Parameter p) |
protected XmlBuilder |
attributesToXml(Attributes atts) |
protected void |
closeDirContext(DirContext dirContext) |
void |
configure()
configure() is called once at startup of the framework in the configure method of the owner of this sender. |
protected DirContext |
getDirContext(Map<String,Object> paramValueMap) |
ParameterList |
getParameterList() |
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.
|
boolean |
isSynchronous()
When
true , the result of sendMessage is the reply of the request. |
protected DirContext |
loopkupDirContext(Map<String,Object> paramValueMap)
Retrieves the DirContext from the JNDI environment and sets the
providerURL back to ldapProviderURL if specified. |
void |
open()
This method will be called to start the sender.
|
String |
performOperation(Message message,
PipeLineSession session)
Performs the specified operation and returns the results.
|
protected Attributes |
removeValuesFromAttributes(Attributes input)
Strips all the values from the attributes in
input . |
SenderResult |
sendMessage(Message message,
PipeLineSession session)
Send a message to some destination (as configured in the Sender object).
|
void |
setAttributesToReturn(String string)
Comma separated list of attributes to return.
|
void |
setErrorSessionKey(String string)
Key of session variable used to store cause of errors
|
void |
setLdapProviderURL(String string)
URL to context to search in, e.g.
|
void |
setManipulationSubject(LdapSender.Manipulation value)
Specifies subject to perform operation on.
|
void |
setMaxEntriesReturned(int i)
The maximum number of entries to be returned by a search query, or
0 for unlimited |
void |
setOperation(LdapSender.Operation value)
Specifies LDAP operation to perform
|
void |
setReplyNotFound(boolean b)
(Only used when
operation=search/deepsearch ) when true the xml '<ldapresult>object not found</ldapresult>' is returned instead of the PartialResultException 'unprocessed continuation reference(s)' |
void |
setSearchTimeout(int i)
Specifies the time (in ms) that is spent searching for results for operation search
|
void |
setUnicodePwd(boolean b)
When
true the 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 |
void |
setUsePooling(boolean b)
Specifies whether connection pooling is used or not
|
void |
storeLdapException(Throwable t,
PipeLineSession session) |
close, getContext, getJndiEnv, setAuthentication, setCredentials, setInitialContextFactoryName, setJmsRealm, setJndiAuthAlias, setJndiContextPrefix, setJndiProperties, setName, setPrincipal, setProviderURL, setSecurityProtocol, setUrlPkgPrefixes, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
consumesSessionVariable
close, sendMessageOrThrow
getName, setName
getApplicationContext, getName
getConfigurationClassLoader
public static final String LDAP_ERROR_MAGIC_STRING
public LdapSender.Operation operation
protected ParameterList paramList
public void configure() throws ConfigurationException
ISender
configure()
is called once at startup of the framework in the configure method of the owner of this sender.
Purpose of this method is to check whether the static configuration of the sender is correct.
As much as possible class-instantiating should take place in the configure()
or open()
method, to improve performance.configure
in interface IConfigurable
configure
in interface ISender
configure
in class JndiBase
ConfigurationException
public void storeLdapException(Throwable t, PipeLineSession session)
public void open() throws SenderException
ISender
sendMessage()
method.open
in interface ISender
SenderException
public boolean isSynchronous()
ISender
true
, the result of sendMessage is the reply of the request.isSynchronous
in interface ISender
public String performOperation(Message message, PipeLineSession session) throws SenderException, ParameterException
SenderException
ParameterException
public String[] getSubContextList(DirContext parentContext, String relativeContext, PipeLineSession session)
public SenderResult sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException
ISender
configure()
method is called.
The following table shows the difference between synchronous and a-synchronous senders:
synchronous | a-synchronous | |
---|---|---|
ISender.isSynchronous() returns | true | false |
return value of sendMessage() is | the 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
.
sendMessage
in interface ISender
SenderException
TimeoutException
protected Attributes removeValuesFromAttributes(Attributes input)
input
. 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.protected DirContext loopkupDirContext(Map<String,Object> paramValueMap) throws NamingException, ParameterException
providerURL
back to ldapProviderURL
if specified.NamingException
ParameterException
protected DirContext getDirContext(Map<String,Object> paramValueMap) throws SenderException, ParameterException
SenderException
ParameterException
protected void closeDirContext(DirContext dirContext)
protected XmlBuilder attributesToXml(Attributes atts) throws NamingException
NamingException
public void addParameter(Parameter p)
addParameter
in interface IWithParameters
public ParameterList getParameterList()
getParameterList
in interface IWithParameters
public void setOperation(LdapSender.Operation value)
public void setLdapProviderURL(String string)
public void setManipulationSubject(LdapSender.Manipulation value)
public void setAttributesToReturn(String string)
public void setUsePooling(boolean b)
public void setSearchTimeout(int i)
public void setErrorSessionKey(String string)
public void setMaxEntriesReturned(int i)
0
for unlimitedpublic void setUnicodePwd(boolean b)
true
the 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 serverpublic void setReplyNotFound(boolean b)
operation=search/deepsearch
) when true
the xml '<ldapresult>object not found</ldapresult>' is returned instead of the PartialResultException 'unprocessed continuation reference(s)'Copyright © 2023 Frank!Framework. All rights reserved.