public class SimpleLdapTemplate extends Object implements SimpleLdapOperations
getLdapOperations() method if you need to invoke less
commonly used template methods.| Constructor and Description |
|---|
SimpleLdapTemplate(ContextSource contextSource)
Deprecated.
Constructs a new SimpleLdapTemplate instance, automatically creating a
wrapped LdapTemplate instance to work with.
|
SimpleLdapTemplate(LdapOperations ldapOperations)
Deprecated.
Constructs a new SimpleLdapTemplate instance wrapping the supplied
LdapOperations instance.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
authenticate(Name base,
String filter,
String password)
Deprecated.
Utility method to perform a simple LDAP 'bind' authentication.
|
boolean |
authenticate(String base,
String filter,
String password)
Deprecated.
Utility method to perform a simple LDAP 'bind' authentication.
|
void |
bind(DirContextOperations ctx)
Deprecated.
Bind the data in the supplied context in the tree.
|
void |
bind(Name dn,
Object obj,
Attributes attributes)
Deprecated.
Create an entry in the LDAP tree.
|
void |
bind(String dn,
Object obj,
Attributes attributes)
Deprecated.
Create an entry in the LDAP tree.
|
LdapOperations |
getLdapOperations()
Deprecated.
Get the wrapped LdapOperations instance.
|
<T> T |
lookup(Name dn,
ParameterizedContextMapper<T> mapper)
Deprecated.
Perform a lookup of the specified DN and map the result using the mapper.
|
<T> T |
lookup(String dn,
ParameterizedContextMapper<T> mapper)
Deprecated.
Perform a lookup of the specified DN and map the result using the mapper.
|
DirContextOperations |
lookupContext(Name dn)
Deprecated.
Look up the specified DN, and automatically cast it to a
DirContextOperations instance. |
DirContextOperations |
lookupContext(String dn)
Deprecated.
Look up the specified DN, and automatically cast it to a
DirContextOperations instance. |
void |
modifyAttributes(DirContextOperations ctx)
Deprecated.
Modify the Attributes of the entry corresponding to the supplied
DirContextOperations instance. |
<T> List<T> |
search(Name base,
String filter,
ParameterizedContextMapper<T> mapper)
Deprecated.
Search for a List of type T using the supplied filter and link
ParameterizedContextMapper.
|
<T> List<T> |
search(Name base,
String filter,
SearchControls controls,
ParameterizedContextMapper<T> mapper,
DirContextProcessor processor)
Deprecated.
Search for a List of type T using the supplied filter, SearchControls,
DirContextProcessor and ParameterizedContextMapper.
|
<T> List<T> |
search(String base,
String filter,
ParameterizedContextMapper<T> mapper)
Deprecated.
Search for a List of type T using the supplied filter and link
ParameterizedContextMapper.
|
<T> List<T> |
search(String base,
String filter,
SearchControls controls,
ParameterizedContextMapper<T> mapper,
DirContextProcessor processor)
Deprecated.
Search for a List of type T using the supplied filter, SearchControls,
DirContextProcessor and ParameterizedContextMapper.
|
<T> T |
searchForObject(Name base,
String filter,
ParameterizedContextMapper<T> mapper)
Deprecated.
Perform a search for a unique entry matching the specified search
criteria and return the found object.
|
<T> T |
searchForObject(String base,
String filter,
ParameterizedContextMapper<T> mapper)
Deprecated.
Perform a search for a unique entry matching the specified search
criteria and return the found object.
|
void |
unbind(Name dn)
Deprecated.
Remove an entry from the LDAP tree.
|
void |
unbind(String dn)
Deprecated.
Remove an entry from the LDAP tree.
|
public SimpleLdapTemplate(LdapOperations ldapOperations)
ldapOperations - the LdapOperations instance to wrap.public SimpleLdapTemplate(ContextSource contextSource)
contextSource - public LdapOperations getLdapOperations()
getLdapOperations in interface SimpleLdapOperationspublic <T> T lookup(String dn, ParameterizedContextMapper<T> mapper)
lookup in interface SimpleLdapOperationsdn - the Distinguished Name to look up.mapper - the mapper to use.public <T> List<T> search(String base, String filter, ParameterizedContextMapper<T> mapper)
search in interface SimpleLdapOperationsbase - Base DN relative to the base of the ContextSource - where to
start the search.filter - Search filter.mapper - the Mapper to supply all results to.public <T> List<T> search(String base, String filter, SearchControls controls, ParameterizedContextMapper<T> mapper, DirContextProcessor processor)
search in interface SimpleLdapOperationsbase - Base DN relative to the base of the ContextSource - where to
start the search.filter - Search filter.controls - the SearchControls. Make sure that the returningObjFlag
is set to true.mapper - the Mapper to supply all results to.processor - the DirContextProcessor to be used for applying pre/post
processing on the DirContext instance.public DirContextOperations lookupContext(String dn)
DirContextOperations instance.lookupContext in interface SimpleLdapOperationsdn - The Distinguished Name of the entry to look up.DirContextOperations instance constructed from the
found entry.public void modifyAttributes(DirContextOperations ctx)
DirContextOperations instance. The instance should have been
received from the SimpleLdapOperations.lookupContext(String) operation, and then
modified to match the current state of the matching domain object, e.g.:
public void update(Person person) {
DirContextOperations ctx = simpleLdapOperations.lookup(person.getDn());
ctx.setAttributeValue("description", person.getDescription());
ctx.setAttributeValue("telephoneNumber", person.getPhone());
// More modifications here
simpleLdapOperations.modifyAttributes(ctx);
}
modifyAttributes in interface SimpleLdapOperationsctx - the entry to update in the LDAP tree.public void bind(String dn, Object obj, Attributes attributes)
obj parameter or the
attributes parameter (or both). One of these parameters may
be null but not both.bind in interface SimpleLdapOperationsdn - The distinguished name to bind the object and attributes to.obj - The object to bind, may be null. Typically a DirContext
implementation.attributes - The attributes to bind, may be null.public void unbind(String dn)
unbind in interface SimpleLdapOperationsdn - The distinguished name to unbind.public void bind(Name dn, Object obj, Attributes attributes)
obj parameter or the
attributes parameter (or both). One of these parameters may
be null but not both.bind in interface SimpleLdapOperationsdn - The distinguished name to bind the object and attributes to.obj - The object to bind, may be null. Typically a DirContext
implementation.attributes - The attributes to bind, may be null.public <T> T lookup(Name dn, ParameterizedContextMapper<T> mapper)
lookup in interface SimpleLdapOperationsdn - the Distinguished Name to look up.mapper - the mapper to use.public DirContextOperations lookupContext(Name dn)
DirContextOperations instance.lookupContext in interface SimpleLdapOperationsdn - The Distinguished Name of the entry to look up.DirContextOperations instance constructed from the
found entry.public <T> List<T> search(Name base, String filter, ParameterizedContextMapper<T> mapper)
search in interface SimpleLdapOperationsbase - Base DN relative to the base of the ContextSource - where to
start the search.filter - Search filter.mapper - the Mapper to supply all results to.public <T> List<T> search(Name base, String filter, SearchControls controls, ParameterizedContextMapper<T> mapper, DirContextProcessor processor)
search in interface SimpleLdapOperationsbase - Base DN relative to the base of the ContextSource - where to
start the search.filter - Search filter.controls - the SearchControls. Make sure that the returningObjFlag
is set to true.mapper - the Mapper to supply all results to.processor - the DirContextProcessor to be used for applying pre/post
processing on the DirContext instance.public void unbind(Name dn)
unbind in interface SimpleLdapOperationsdn - The distinguished name to unbind.public void bind(DirContextOperations ctx)
bind in interface SimpleLdapOperationsctx - the context to bindpublic <T> T searchForObject(String base, String filter, ParameterizedContextMapper<T> mapper)
IncorrectResultSizeDataAccessException is thrown.searchForObject in interface SimpleLdapOperationsbase - the DN to use as the base of the search.filter - the search filter.mapper - the mapper to use for the search.public <T> T searchForObject(Name base, String filter, ParameterizedContextMapper<T> mapper)
IncorrectResultSizeDataAccessException is thrown.searchForObject in interface SimpleLdapOperationsbase - the DN to use as the base of the search.filter - the search filter.mapper - the mapper to use for the search.public boolean authenticate(String base, String filter, String password)
ContextSource.getContext(String, String), thus authenticating the
entry.
Example:
AndFilter filter = new AndFilter();
filter.and("objectclass", "person").and("uid", userId);
boolean authenticated = ldapTemplate.authenticate(LdapUtils.emptyLdapName(),
filter.toString(), password);
authenticate in interface SimpleLdapOperationsbase - the DN to use as the base of the search.filter - the search filter - must result in a unique result.password - the password to use for authentication.true if the authentication was successful,
false otherwise.public boolean authenticate(Name base, String filter, String password)
ContextSource.getContext(String, String), thus authenticating the
entry.
Example:
AndFilter filter = new AndFilter();
filter.and("objectclass", "person").and("uid", userId);
boolean authenticated = ldapTemplate.authenticate(LdapUtils.emptyLdapName(),
filter.toString(), password);
authenticate in interface SimpleLdapOperationsbase - the DN to use as the base of the search.filter - the search filter - must result in a unique result.password - the password to use for authentication.true if the authentication was successful,
false otherwise.