|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.ldap.core.simple.SimpleLdapTemplate
public class SimpleLdapTemplate
Java-5-based convenience wrapper for the classic LdapTemplate, adding some
convenient shortcuts and taking advantage of Java 5 Generics.
Use the getLdapOperations()
method if you need to invoke less
commonly used template methods.
Constructor Summary | |
---|---|
SimpleLdapTemplate(ContextSource contextSource)
Constructs a new SimpleLdapTemplate instance, automatically creating a wrapped LdapTemplate instance to work with. |
|
SimpleLdapTemplate(LdapOperations ldapOperations)
Constructs a new SimpleLdapTemplate instance wrapping the supplied LdapOperations instance. |
Method Summary | ||
---|---|---|
void |
bind(String dn,
Object obj,
Attributes attributes)
Create an entry in the LDAP tree. |
|
LdapOperations |
getLdapOperations()
Get the wrapped LdapOperations instance. |
|
|
lookup(String dn,
ParameterizedContextMapper<T> mapper)
Perform a lookup of the specified DN and map the result using the mapper. |
|
DirContextOperations |
lookupContext(String dn)
Look up the specified DN, and automatically cast it to a DirContextOperations instance. |
|
void |
modifyAttributes(DirContextOperations ctx)
Modify the Attributes of the entry corresponding to the supplied DirContextOperations instance. |
|
|
search(String base,
String filter,
ParameterizedContextMapper<T> mapper)
Search for a List of type T using the supplied filter and link ParametrizedContextMapper. |
|
|
search(String base,
String filter,
SearchControls controls,
ParameterizedContextMapper<T> mapper,
DirContextProcessor processor)
Search for a List of type T using the supplied filter, SearchControls, DirContextProcessor and ParametrizedContextMapper. |
|
void |
unbind(String dn)
Remove an entry from the LDAP tree. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleLdapTemplate(LdapOperations ldapOperations)
ldapOperations
- the LdapOperations instance to wrap.public SimpleLdapTemplate(ContextSource contextSource)
contextSource
- Method Detail |
---|
public LdapOperations getLdapOperations()
SimpleLdapOperations
getLdapOperations
in interface SimpleLdapOperations
public <T> T lookup(String dn, ParameterizedContextMapper<T> mapper)
SimpleLdapOperations
lookup
in interface SimpleLdapOperations
dn
- the Distinguished Name to look up.mapper
- the mapper to use.
public <T> List<T> search(String base, String filter, ParameterizedContextMapper<T> mapper)
SimpleLdapOperations
search
in interface SimpleLdapOperations
base
- 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)
SimpleLdapOperations
search
in interface SimpleLdapOperations
base
- 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)
SimpleLdapOperations
DirContextOperations
instance.
lookupContext
in interface SimpleLdapOperations
dn
- The Distinguished Name of the entry to look up.
DirContextOperations
instance constructed from the
found entry.public void modifyAttributes(DirContextOperations ctx)
SimpleLdapOperations
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 SimpleLdapOperations
ctx
- the entry to update in the LDAP tree.public void bind(String dn, Object obj, Attributes attributes)
SimpleLdapOperations
obj
parameter or the
attributes
parameter (or both). One of these parameters
may be null but not both.
bind
in interface SimpleLdapOperations
dn
- 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)
SimpleLdapOperations
unbind
in interface SimpleLdapOperations
dn
- The distinguished name to unbind.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |