|
Spring LDAP | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SimpleLdapOperations
LDAP operations interface usable on Java 5 and above, exposing a set of common LDAP operations.
Method Summary | ||
---|---|---|
boolean |
authenticate(Name base,
String filter,
String password)
Utility method to perform a simple LDAP 'bind' authentication. |
|
boolean |
authenticate(String base,
String filter,
String password)
Utility method to perform a simple LDAP 'bind' authentication. |
|
void |
bind(DirContextOperations ctx)
Bind the data in the supplied context in the tree. |
|
void |
bind(Name dn,
Object obj,
Attributes attributes)
Create an entry in the LDAP tree. |
|
void |
bind(String dn,
Object obj,
Attributes attributes)
Create an entry in the LDAP tree. |
|
LdapOperations |
getLdapOperations()
Get the wrapped LdapOperations instance. |
|
|
lookup(Name dn,
ParameterizedContextMapper<T> mapper)
Perform a lookup of the specified DN and map the result using the mapper. |
|
|
lookup(String dn,
ParameterizedContextMapper<T> mapper)
Perform a lookup of the specified DN and map the result using the mapper. |
|
DirContextOperations |
lookupContext(Name dn)
Look up the specified DN, and automatically cast it to a DirContextOperations instance. |
|
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(Name base,
String filter,
ParameterizedContextMapper<T> mapper)
Search for a List of type T using the supplied filter and link ParameterizedContextMapper. |
|
|
search(Name base,
String filter,
SearchControls controls,
ParameterizedContextMapper<T> mapper,
DirContextProcessor processor)
Search for a List of type T using the supplied filter, SearchControls, DirContextProcessor and ParameterizedContextMapper. |
|
|
search(String base,
String filter,
ParameterizedContextMapper<T> mapper)
Search for a List of type T using the supplied filter and link ParameterizedContextMapper. |
|
|
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 ParameterizedContextMapper. |
|
|
searchForObject(Name base,
String filter,
ParameterizedContextMapper<T> mapper)
Perform a search for a unique entry matching the specified search criteria and return the found object. |
|
|
searchForObject(String base,
String filter,
ParameterizedContextMapper<T> mapper)
Perform a search for a unique entry matching the specified search criteria and return the found object. |
|
void |
unbind(Name dn)
Remove an entry from the LDAP tree. |
|
void |
unbind(String dn)
Remove an entry from the LDAP tree. |
Method Detail |
---|
LdapOperations getLdapOperations()
NamingException
- if any error occurs.<T> List<T> search(String base, String filter, ParameterizedContextMapper<T> mapper)
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.
NamingException
- if any error occurs.<T> List<T> search(Name base, String filter, ParameterizedContextMapper<T> mapper)
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.
NamingException
- if any error occurs.<T> List<T> search(String base, String filter, SearchControls controls, ParameterizedContextMapper<T> mapper, DirContextProcessor processor)
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.
NamingException
- if any error occurs.<T> List<T> search(Name base, String filter, SearchControls controls, ParameterizedContextMapper<T> mapper, DirContextProcessor processor)
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.
NamingException
- if any error occurs.<T> T lookup(String dn, ParameterizedContextMapper<T> mapper)
dn
- the Distinguished Name to look up.mapper
- the mapper to use.
NamingException
- if any error occurs.<T> T lookup(Name dn, ParameterizedContextMapper<T> mapper)
dn
- the Distinguished Name to look up.mapper
- the mapper to use.
NamingException
- if any error occurs.<T> T searchForObject(String base, String filter, ParameterizedContextMapper<T> mapper)
IncorrectResultSizeDataAccessException
is thrown.
base
- the DN to use as the base of the search.filter
- the search filter.mapper
- the mapper to use for the search.
IncorrectResultSizeDataAccessException
- if the result is not one
unique entry<T> T searchForObject(Name base, String filter, ParameterizedContextMapper<T> mapper)
IncorrectResultSizeDataAccessException
is thrown.
base
- the DN to use as the base of the search.filter
- the search filter.mapper
- the mapper to use for the search.
IncorrectResultSizeDataAccessException
- if the result is not one
unique entryDirContextOperations lookupContext(String dn)
DirContextOperations
instance.
dn
- The Distinguished Name of the entry to look up.
DirContextOperations
instance constructed from the
found entry.
NamingException
- if any error occurs.DirContextOperations lookupContext(Name dn)
DirContextOperations
instance.
dn
- The Distinguished Name of the entry to look up.
DirContextOperations
instance constructed from the
found entry.
NamingException
- if any error occurs.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.
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.
NamingException
- if any error occurs.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.
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.
NamingException
- if any error occurs.void bind(DirContextOperations ctx)
ctx
- the context to bind
IllegalStateException
- if no DN is set or if the instance is in
update mode.void unbind(String dn)
dn
- The distinguished name to unbind.
NamingException
- if any error occurs.void unbind(Name dn)
dn
- The distinguished name to unbind.
NamingException
- if any error occurs.void modifyAttributes(DirContextOperations ctx)
DirContextOperations
instance. The instance should have been
received from the 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); }
ctx
- the entry to update in the LDAP tree.
NamingException
- if any error occurs.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(DistinguishedName.EMPTY_PATH, filter.toString(), password);
base
- 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.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(DistinguishedName.EMPTY_PATH, filter.toString(), password);
base
- 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.
|
Spring LDAP | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |