|
Spring LDAP Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.ldap.core.LdapTemplate
public class LdapTemplate
Executes core LDAP functionality and helps to avoid common errors, relieving the user of the burden of looking up contexts, looping through NamingEnumerations and closing contexts.
Note for Active Directory (AD) users: AD servers are apparently unable
to handle referrals automatically, which causes a
PartialResultException to be thrown whenever a referral is
encountered in a search. To avoid this, set the
ignorePartialResultException property to true.
There is currently no way of manually handling these referrals in the form of
ReferralException, i.e. either you get the exception (and your
results are lost) or all referrals are ignored (if the server is unable to
handle them properly. Neither is there any simple way to get notified that a
PartialResultException has been ignored (other than in the log).
ContextSource| Nested Class Summary | |
|---|---|
static class |
LdapTemplate.MappingCollectingNameClassPairCallbackHandler
A NameClassPairCallbackHandler that passes the NameClassPairs
found to a NameClassPairMapper and collects the results in a list. |
| Constructor Summary | |
|---|---|
LdapTemplate()
Constructor for bean usage. |
|
LdapTemplate(ContextSource contextSource)
Constructor to setup instance directly. |
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
|
boolean |
authenticate(Name base,
String filter,
String password)
Utility method to perform a simple LDAP 'bind' authentication. |
boolean |
authenticate(Name base,
String filter,
String password,
AuthenticatedLdapEntryContextCallback callback)
Utility method to perform a simple LDAP 'bind' authentication. |
boolean |
authenticate(Name base,
String filter,
String password,
AuthenticatedLdapEntryContextCallback callback,
AuthenticationErrorCallback errorCallback)
Utility method to perform a simple LDAP 'bind' authentication. |
boolean |
authenticate(Name base,
String filter,
String password,
AuthenticationErrorCallback errorCallback)
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. |
boolean |
authenticate(String base,
String filter,
String password,
AuthenticatedLdapEntryContextCallback callback)
Utility method to perform a simple LDAP 'bind' authentication. |
boolean |
authenticate(String base,
String filter,
String password,
AuthenticatedLdapEntryContextCallback callback,
AuthenticationErrorCallback errorCallback)
Utility method to perform a simple LDAP 'bind' authentication. |
boolean |
authenticate(String base,
String filter,
String password,
AuthenticationErrorCallback errorCallback)
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. |
protected void |
deleteRecursively(DirContext ctx,
DistinguishedName name)
Delete all subcontexts including the current one recursively. |
Object |
executeReadOnly(ContextExecutor ce)
Perform an operation (or series of operations) on a read-only context. |
Object |
executeReadWrite(ContextExecutor ce)
Perform an operation (or series of operations) on a read-write context. |
ContextSource |
getContextSource()
Get the ContextSource. |
List |
list(Name base)
Perform a non-recursive listing of the children of the given base. |
void |
list(Name base,
NameClassPairCallbackHandler handler)
Perform a non-recursive listing of the children of the given base. |
List |
list(Name base,
NameClassPairMapper mapper)
Perform a non-recursive listing of the children of the given base. |
List |
list(String base)
Perform a non-recursive listing of the children of the given base. |
void |
list(String base,
NameClassPairCallbackHandler handler)
Perform a non-recursive listing of the children of the given base. |
List |
list(String base,
NameClassPairMapper mapper)
Perform a non-recursive listing of the children of the given base. |
List |
listBindings(Name base)
Perform a non-recursive listing of children of the given base. |
List |
listBindings(Name base,
ContextMapper mapper)
Perform a non-recursive listing of the children of the given base. |
void |
listBindings(Name base,
NameClassPairCallbackHandler handler)
Perform a non-recursive listing of the children of the given base. |
List |
listBindings(Name base,
NameClassPairMapper mapper)
Perform a non-recursive listing of the children of the given base. |
List |
listBindings(String base)
Perform a non-recursive listing of children of the given base. |
List |
listBindings(String base,
ContextMapper mapper)
Perform a non-recursive listing of the children of the given base. |
void |
listBindings(String base,
NameClassPairCallbackHandler handler)
Perform a non-recursive listing of the children of the given base. |
List |
listBindings(String base,
NameClassPairMapper mapper)
Perform a non-recursive listing of the children of the given base. |
Object |
lookup(Name dn)
Lookup the supplied DN and return the found object. |
Object |
lookup(Name dn,
AttributesMapper mapper)
Convenience method to get the attributes of a specified DN and automatically pass them to an AttributesMapper. |
Object |
lookup(Name dn,
ContextMapper mapper)
Convenience method to lookup a specified DN and automatically pass the found object to a ContextMapper. |
Object |
lookup(Name dn,
String[] attributes,
AttributesMapper mapper)
Convenience method to get the specified attributes of a specified DN and automatically pass them to an AttributesMapper. |
Object |
lookup(Name dn,
String[] attributes,
ContextMapper mapper)
Convenience method to get the specified attributes of a specified DN and automatically pass them to a ContextMapper. |
Object |
lookup(String dn)
Lookup the supplied DN and return the found object. |
Object |
lookup(String dn,
AttributesMapper mapper)
Convenience method to get the attributes of a specified DN and automatically pass them to an AttributesMapper. |
Object |
lookup(String dn,
ContextMapper mapper)
Convenience method to lookup a specified DN and automatically pass the found object to a ContextMapper. |
Object |
lookup(String dn,
String[] attributes,
AttributesMapper mapper)
Convenience method to get the specified attributes of a specified DN and automatically pass them to an AttributesMapper. |
Object |
lookup(String dn,
String[] attributes,
ContextMapper mapper)
Convenience method to get the specified attributes of a specified DN and automatically pass them to a ContextMapper. |
DirContextOperations |
lookupContext(Name dn)
Convenience method to lookup the supplied DN and automatically cast it to DirContextOperations. |
DirContextOperations |
lookupContext(String dn)
Convenience method to lookup the supplied DN and automatically cast it to DirContextOperations. |
void |
modifyAttributes(DirContextOperations ctx)
Modify the attributes of the entry referenced by the supplied DirContextOperations instance. |
void |
modifyAttributes(Name dn,
ModificationItem[] mods)
Modify an entry in the LDAP tree using the supplied ModificationItems. |
void |
modifyAttributes(String dn,
ModificationItem[] mods)
Modify an entry in the LDAP tree using the supplied ModificationItems. |
void |
rebind(DirContextOperations ctx)
Remove an entry and replace it with a new one. |
void |
rebind(Name dn,
Object obj,
Attributes attributes)
Remove an entry and replace it with a new one. |
void |
rebind(String dn,
Object obj,
Attributes attributes)
Remove an entry and replace it with a new one. |
void |
rename(Name oldDn,
Name newDn)
Move an entry in the LDAP tree to a new location. |
void |
rename(String oldDn,
String newDn)
Move an entry in the LDAP tree to a new location. |
List |
search(Name base,
String filter,
AttributesMapper mapper)
Search for all objects matching the supplied filter. |
List |
search(Name base,
String filter,
ContextMapper mapper)
Search for all objects matching the supplied filter. |
List |
search(Name base,
String filter,
int searchScope,
AttributesMapper mapper)
Search for all objects matching the supplied filter. |
void |
search(Name base,
String filter,
int searchScope,
boolean returningObjFlag,
NameClassPairCallbackHandler handler)
Search for all objects matching the supplied filter. |
List |
search(Name base,
String filter,
int searchScope,
ContextMapper mapper)
Search for all objects matching the supplied filter. |
List |
search(Name base,
String filter,
int searchScope,
String[] attrs,
AttributesMapper mapper)
Search for all objects matching the supplied filter. |
List |
search(Name base,
String filter,
int searchScope,
String[] attrs,
ContextMapper mapper)
Search for all objects matching the supplied filter. |
void |
search(Name base,
String filter,
NameClassPairCallbackHandler handler)
Search for all objects matching the supplied filter. |
List |
search(Name base,
String filter,
SearchControls controls,
AttributesMapper mapper)
Search for all objects matching the supplied filter. |
List |
search(Name base,
String filter,
SearchControls controls,
AttributesMapper mapper,
DirContextProcessor processor)
Search for all objects matching the supplied filter. |
List |
search(Name base,
String filter,
SearchControls controls,
ContextMapper mapper)
Search for all objects matching the supplied filter. |
List |
search(Name base,
String filter,
SearchControls controls,
ContextMapper mapper,
DirContextProcessor processor)
Search for all objects matching the supplied filter. |
void |
search(Name base,
String filter,
SearchControls controls,
NameClassPairCallbackHandler handler)
Search for all objects matching the supplied filter. |
void |
search(Name base,
String filter,
SearchControls controls,
NameClassPairCallbackHandler handler,
DirContextProcessor processor)
Search for all objects matching the supplied filter. |
void |
search(SearchExecutor se,
NameClassPairCallbackHandler handler)
Perform a search operation, such as a search(), list() or listBindings(). |
void |
search(SearchExecutor se,
NameClassPairCallbackHandler handler,
DirContextProcessor processor)
Perform a search operation, such as a search(), list() or listBindings(). |
List |
search(String base,
String filter,
AttributesMapper mapper)
Search for all objects matching the supplied filter. |
List |
search(String base,
String filter,
ContextMapper mapper)
Search for all objects matching the supplied filter. |
List |
search(String base,
String filter,
int searchScope,
AttributesMapper mapper)
Search for all objects matching the supplied filter. |
void |
search(String base,
String filter,
int searchScope,
boolean returningObjFlag,
NameClassPairCallbackHandler handler)
Search for all objects matching the supplied filter. |
List |
search(String base,
String filter,
int searchScope,
ContextMapper mapper)
Search for all objects matching the supplied filter. |
List |
search(String base,
String filter,
int searchScope,
String[] attrs,
AttributesMapper mapper)
Search for all objects matching the supplied filter. |
List |
search(String base,
String filter,
int searchScope,
String[] attrs,
ContextMapper mapper)
Search for all objects matching the supplied filter. |
void |
search(String base,
String filter,
NameClassPairCallbackHandler handler)
Search for all objects matching the supplied filter. |
List |
search(String base,
String filter,
SearchControls controls,
AttributesMapper mapper)
Search for all objects matching the supplied filter. |
List |
search(String base,
String filter,
SearchControls controls,
AttributesMapper mapper,
DirContextProcessor processor)
Search for all objects matching the supplied filter. |
List |
search(String base,
String filter,
SearchControls controls,
ContextMapper mapper)
Search for all objects matching the supplied filter. |
List |
search(String base,
String filter,
SearchControls controls,
ContextMapper mapper,
DirContextProcessor processor)
Search for all objects matching the supplied filter. |
void |
search(String base,
String filter,
SearchControls controls,
NameClassPairCallbackHandler handler)
Search for all objects matching the supplied filter. |
void |
search(String base,
String filter,
SearchControls controls,
NameClassPairCallbackHandler handler,
DirContextProcessor processor)
Search for all objects matching the supplied filter. |
Object |
searchForObject(Name base,
String filter,
ContextMapper mapper)
Perform a search for a unique entry matching the specified search criteria and return the found object. |
Object |
searchForObject(String base,
String filter,
ContextMapper mapper)
Perform a search for a unique entry matching the specified search criteria and return the found object. |
void |
setContextSource(ContextSource contextSource)
Set the ContextSource. |
void |
setIgnoreNameNotFoundException(boolean ignore)
Specify whether NameNotFoundException should be ignored in
searches. |
void |
setIgnorePartialResultException(boolean ignore)
Specify whether PartialResultException should be ignored in
searches. |
void |
unbind(Name dn)
Remove an entry from the LDAP tree. |
void |
unbind(Name dn,
boolean recursive)
Remove an entry from the LDAP tree, optionally removing all descendants in the process. |
void |
unbind(String dn)
Remove an entry from the LDAP tree. |
void |
unbind(String dn,
boolean recursive)
Remove an entry from the LDAP tree, optionally removing all descendants in the process. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LdapTemplate()
public LdapTemplate(ContextSource contextSource)
contextSource - the ContextSource to use.| Method Detail |
|---|
public void setContextSource(ContextSource contextSource)
contextSource - the ContextSource.public ContextSource getContextSource()
public void setIgnoreNameNotFoundException(boolean ignore)
NameNotFoundException should be ignored in
searches. In previous version, NameNotFoundException caused
by the search base not being found was silently ignored. The default
behavior is now to treat this as an error (as it should), and to convert
and re-throw the exception. The ability to revert to the previous
behavior still exists. The only difference is that the incident is in
that case no longer silently ignored, but logged as a warning.
ignore - true if NameNotFoundException
should be ignored in searches, false otherwise. Default is
false.public void setIgnorePartialResultException(boolean ignore)
PartialResultException should be ignored in
searches. AD servers typically have a problem with referrals. Normally a
referral should be followed automatically, but this does not seem to work
with AD servers. The problem manifests itself with a a
PartialResultException being thrown when a referral is
encountered by the server. Setting this property to true
presents a workaround to this problem by causing
PartialResultException to be ignored, so that the search
method returns normally. Default value of this parameter is
false.
ignore - true if PartialResultException
should be ignored in searches, false otherwise. Default is
false.
public void search(Name base,
String filter,
int searchScope,
boolean returningObjFlag,
NameClassPairCallbackHandler handler)
LdapOperationsSearchResult is supplied to the specified
NameClassPairCallbackHandler. Use the specified values for
search scope and return objects flag.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.searchScope - The search scope to set in SearchControls
.returningObjFlag - Whether the bound object should be returned in
search results. Must be set to true if a
ContextMapper is used.handler - The NameClassPairCallbackHandler to supply
the SearchResults to.
public void search(String base,
String filter,
int searchScope,
boolean returningObjFlag,
NameClassPairCallbackHandler handler)
LdapOperationsSearchResult is supplied to the specified
NameClassPairCallbackHandler. Use the specified values for
search scope and return objects flag.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.searchScope - The search scope to set in SearchControls
.returningObjFlag - Whether the bound object should be returned in
search results. Must be set to true if a
ContextMapper is used.handler - The NameClassPairCallbackHandler to supply
the SearchResults to.
public void search(Name base,
String filter,
SearchControls controls,
NameClassPairCallbackHandler handler)
LdapOperationsSearchResult is supplied to the specified
NameClassPairCallbackHandler. The SearchScope
specified in the supplied SearchControls will be used in the
search. Note that if you are using a ContextMapper, the
returningObjFlag needs to be set to true in the
SearchControls.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.controls - The SearchControls to use in the search.handler - The NameClassPairCallbackHandler to supply
the SearchResult to.
public void search(String base,
String filter,
SearchControls controls,
NameClassPairCallbackHandler handler)
LdapOperationsLdapOperations.search(Name, String, SearchControls, NameClassPairCallbackHandler)
for details.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.controls - The SearchControls to use in the search.handler - The NameClassPairCallbackHandler to supply
the SearchResult to.
public void search(Name base,
String filter,
SearchControls controls,
NameClassPairCallbackHandler handler,
DirContextProcessor processor)
LdapOperationsSearchResult is supplied to the specified
NameClassPairCallbackHandler. The SearchScope
specified in the supplied SearchControls will be used in the
search. Note that if you are using a ContextMapper, the
returningObjFlag needs to be set to true in the
SearchControls. The given DirContextProcessor
will be called before and after the search.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.controls - The SearchControls to use in the search.handler - The NameClassPairCallbackHandler to supply
the SearchResult to.processor - The DirContextProcessor to use before and
after the search.
public void search(String base,
String filter,
SearchControls controls,
NameClassPairCallbackHandler handler,
DirContextProcessor processor)
LdapOperationsLdapOperations.search(Name, String, SearchControls, NameClassPairCallbackHandler, DirContextProcessor)
for details.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.controls - The SearchControls to use in the search.handler - The NameClassPairCallbackHandler to supply
the SearchResults to.processor - The DirContextProcessor to use before and
after the search.
public void search(SearchExecutor se,
NameClassPairCallbackHandler handler,
DirContextProcessor processor)
The actual list is delegated to the SearchExecutor and each
NameClassPair (this might be a NameClassPair or a subclass
thereof) is passed to the CallbackHandler. Any encountered
NamingException will be translated using the NamingExceptionTranslator.
search in interface LdapOperationsse - the SearchExecutor to use for performing the actual list.handler - the NameClassPairCallbackHandler to which each found entry
will be passed.processor - DirContextProcessor for custom pre- and post-processing.
Must not be null. If no custom processing should take place,
please use e.g.
search(SearchExecutor, NameClassPairCallbackHandler).
NamingException - if any error occurs. Note that a
NameNotFoundException will be ignored. Instead this is interpreted that
no entries were found.
public void search(SearchExecutor se,
NameClassPairCallbackHandler handler)
The actual list is delegated to the SearchExecutor and each
NameClassPair (this might be a NameClassPair or a subclass
thereof) is passed to the CallbackHandler. Any encountered
NamingException will be translated using the NamingExceptionTranslator.
search in interface LdapOperationsse - the SearchExecutor to use for performing the actual list.handler - the NameClassPairCallbackHandler to which each found entry
will be passed.
NamingException - if any error occurs. Note that a
NameNotFoundException will be ignored. Instead this is interpreted that
no entries were found.LdapOperations.search(Name, String, AttributesMapper),
LdapOperations.search(Name, String, ContextMapper)
public void search(Name base,
String filter,
NameClassPairCallbackHandler handler)
LdapOperationsSearchResult is supplied to the specified
NameClassPairCallbackHandler. The default Search scope (
SearchControls.SUBTREE_SCOPE) will be used and the
returnObjects flag will be set to false.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.handler - The NameClassPairCallbackHandler to supply
the SearchResults to.
public void search(String base,
String filter,
NameClassPairCallbackHandler handler)
LdapOperationsSearchResult is supplied to the specified
NameClassPairCallbackHandler. The default Search scope (
SearchControls.SUBTREE_SCOPE) will be used and the
returnObjects flag will be set to false.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.handler - The NameClassPairCallbackHandler to supply
the SearchResults to.
public List search(Name base,
String filter,
int searchScope,
String[] attrs,
AttributesMapper mapper)
LdapOperationsSearchResult is supplied to the specified
AttributesMapper.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.searchScope - The search scope to set in SearchControls
.attrs - The attributes to return, null means returning
all attributes.mapper - The AttributesMapper to use for translating
each entry.
List containing all entries received from the
AttributesMapper.
public List search(String base,
String filter,
int searchScope,
String[] attrs,
AttributesMapper mapper)
LdapOperationsSearchResult is supplied to the specified
AttributesMapper.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.searchScope - The search scope to set in SearchControls
.attrs - The attributes to return, null means returning
all attributes.mapper - The AttributesMapper to use for translating
each entry.
List containing all entries received from the
AttributesMapper.
public List search(Name base,
String filter,
int searchScope,
AttributesMapper mapper)
LdapOperationsSearchResult is supplied to the specified
AttributesMapper.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.searchScope - The search scope to set in SearchControls
.mapper - The AttributesMapper to use for translating
each entry.
List containing all entries received from the
AttributesMapper.
public List search(String base,
String filter,
int searchScope,
AttributesMapper mapper)
LdapOperationsSearchResult is supplied to the specified
AttributesMapper.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.searchScope - The search scope to set in SearchControls
.mapper - The AttributesMapper to use for translating
each entry.
List containing all entries received from the
AttributesMapper.
public List search(Name base,
String filter,
AttributesMapper mapper)
LdapOperationsSearchResult is supplied to the specified
AttributesMapper. The default search scope will be used.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.mapper - The AttributesMapper to use for translating
each entry.
List containing all entries received from the
AttributesMapper.
public List search(String base,
String filter,
AttributesMapper mapper)
LdapOperationsSearchResult is supplied to the specified
AttributesMapper. The default search scope will be used.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.mapper - The AttributesMapper to use for translating
each entry.
List containing all entries received from the
AttributesMapper.
public List search(Name base,
String filter,
int searchScope,
String[] attrs,
ContextMapper mapper)
LdapOperationsObject returned in each SearchResult is
supplied to the specified ContextMapper. Only return the
supplied attributes.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.searchScope - The search scope to set in SearchControls
.attrs - The attributes to return, null means all
attributes.mapper - The ContextMapper to use for translating each
entry.
List containing all entries received from the
ContextMapper.
public List search(String base,
String filter,
int searchScope,
String[] attrs,
ContextMapper mapper)
LdapOperationsObject returned in each SearchResult is
supplied to the specified ContextMapper. Only return the
supplied attributes.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.searchScope - The search scope to set in SearchControls
.attrs - The attributes to return, null means all
attributes.mapper - The ContextMapper to use for translating each
entry.
List containing all entries received from the
ContextMapper.
public List search(Name base,
String filter,
int searchScope,
ContextMapper mapper)
LdapOperationsObject returned in each SearchResult is
supplied to the specified ContextMapper.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.searchScope - The search scope to set in SearchControls
.mapper - The ContextMapper to use for translating each
entry.
List containing all entries received from the
ContextMapper.
public List search(String base,
String filter,
int searchScope,
ContextMapper mapper)
LdapOperationsObject returned in each SearchResult is
supplied to the specified ContextMapper.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.searchScope - The search scope to set in SearchControls
.mapper - The ContextMapper to use for translating each
entry.
List containing all entries received from the
ContextMapper.
public List search(Name base,
String filter,
ContextMapper mapper)
LdapOperationsObject returned in each SearchResult is
supplied to the specified ContextMapper. The default search
scope (SearchControls.SUBTREE_SCOPE) will be used.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.mapper - The ContextMapper to use for translating each
entry.
List containing all entries received from the
ContextMapper.
public List search(String base,
String filter,
ContextMapper mapper)
LdapOperationsObject returned in each SearchResult is
supplied to the specified ContextMapper. The default search
scope (SearchControls.SUBTREE_SCOPE) will be used.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.mapper - The ContextMapper to use for translating each
entry.
List containing all entries received from the
ContextMapper.
public List search(String base,
String filter,
SearchControls controls,
ContextMapper mapper)
LdapOperationsObject returned in each SearchResult is
supplied to the specified ContextMapper. The default search
scope (SearchControls.SUBTREE_SCOPE) will be used.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.mapper - The ContextMapper to use for translating each
entry.
List containing all entries received from the
ContextMapper.
public List search(Name base,
String filter,
SearchControls controls,
ContextMapper mapper)
LdapOperationsSearchResult is supplied to the specified
ContextMapper.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.controls - The SearchControls to use in the search. If
the returnObjFlag is not set in the SearchControls, this
method will set it automatically, as this is required for the
ContextMapper to work.mapper - The ContextMapper to use for translating each
entry.
List containing all entries received from the
ContextMapper.
public List search(Name base,
String filter,
SearchControls controls,
AttributesMapper mapper)
LdapOperationsSearchResult is supplied to the specified
AttributesMapper.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.controls - The SearchControls to use in the search.mapper - The AttributesMapper to use for translating
each entry.
List containing all entries received from the
ContextMapper.
public List search(String base,
String filter,
SearchControls controls,
AttributesMapper mapper)
LdapOperationsSearchResult is supplied to the specified
AttributesMapper.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.controls - The SearchControls to use in the search.mapper - The AttributesMapper to use for translating
each entry.
List containing all entries received from the
ContextMapper.
public List search(String base,
String filter,
SearchControls controls,
AttributesMapper mapper,
DirContextProcessor processor)
LdapOperationsSearchResult is supplied to the specified
AttributesMapper. The SearchScope specified in
the supplied SearchControls will be used in the search. The
given DirContextProcessor will be called before and after
the search.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.controls - The SearchControls to use in the search.mapper - The AttributesMapper to use for translating
each entry.processor - The DirContextProcessor to use before and
after the search.
List containing all entries received from the
AttributesMapper.
public List search(Name base,
String filter,
SearchControls controls,
AttributesMapper mapper,
DirContextProcessor processor)
LdapOperationsSearchResult is supplied to the specified
AttributesMapper. The SearchScope specified in
the supplied SearchControls will be used in the search. The
given DirContextProcessor will be called before and after
the search.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.controls - The SearchControls to use in the search.mapper - The AttributesMapper to use for translating
each entry.processor - The DirContextProcessor to use before and
after the search.
List containing all entries received from the
AttributesMapper.
public List search(String base,
String filter,
SearchControls controls,
ContextMapper mapper,
DirContextProcessor processor)
LdapOperationsSearchResult is supplied to the specified
ContextMapper. The SearchScope specified in the
supplied SearchControls will be used in the search. The
given DirContextProcessor will be called before and after
the search.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.controls - The SearchControls to use in the search. If
the returnObjFlag is not set in the SearchControls, this
method will set it automatically, as this is required for the
ContextMapper to work.mapper - The ContextMapper to use for translating each
entry.processor - The DirContextProcessor to use before and
after the search.
List containing all entries received from the
ContextMapper.
public List search(Name base,
String filter,
SearchControls controls,
ContextMapper mapper,
DirContextProcessor processor)
LdapOperationsSearchResult is supplied to the specified
ContextMapper. The SearchScope specified in the
supplied SearchControls will be used in the search. The
given DirContextProcessor will be called before and after
the search.
search in interface LdapOperationsbase - The base DN where the search should begin.filter - The filter to use in the search.controls - The SearchControls to use in the search. If
the returnObjFlag is not set in the SearchControls, this
method will set it automatically, as this is required for the
ContextMapper to work.mapper - The ContextMapper to use for translating each
entry.processor - The DirContextProcessor to use before and
after the search.
List containing all entries received from the
ContextMapper.
public void list(String base,
NameClassPairCallbackHandler handler)
LdapOperationsbase. Each resulting NameClassPair is supplied
to the specified NameClassPairCallbackHandler.
list in interface LdapOperationsbase - The base DN where the list should be performed.handler - The NameClassPairCallbackHandler to supply
each NameClassPair to.
public void list(Name base,
NameClassPairCallbackHandler handler)
LdapOperationsbase. Each resulting NameClassPair is supplied
to the specified NameClassPairCallbackHandler.
list in interface LdapOperationsbase - The base DN where the list should be performed.handler - The NameClassPairCallbackHandler to supply
each NameClassPair to.
public List list(String base,
NameClassPairMapper mapper)
LdapOperationsbase. Pass all the found NameClassPair objects
to the supplied NameClassPairMapper and return all the
returned values as a List.
list in interface LdapOperationsbase - The base DN where the list should be performed.mapper - The NameClassPairMapper to supply each
NameClassPair to.
List containing the Objects returned from the
Mapper.
public List list(Name base,
NameClassPairMapper mapper)
LdapOperationsbase. Pass all the found NameClassPair objects
to the supplied NameClassPairMapper and return all the
returned values as a List.
list in interface LdapOperationsbase - The base DN where the list should be performed.mapper - The NameClassPairMapper to supply each
NameClassPair to.
List containing the Objects returned from the
Mapper.public List list(Name base)
LdapOperationsbase.
list in interface LdapOperationsbase - The base DN where the list should be performed.
base.public List list(String base)
LdapOperationsbase.
list in interface LdapOperationsbase - The base DN where the list should be performed.
base.
public void listBindings(String base,
NameClassPairCallbackHandler handler)
LdapOperationsbase. Each resulting Binding is supplied to the
specified NameClassPairCallbackHandler.
listBindings in interface LdapOperationsbase - The base DN where the list should be performed.handler - The NameClassPairCallbackHandler to supply
each Binding to.
public void listBindings(Name base,
NameClassPairCallbackHandler handler)
LdapOperationsbase. Each resulting Binding is supplied to the
specified NameClassPairCallbackHandler.
listBindings in interface LdapOperationsbase - The base DN where the list should be performed.handler - The NameClassPairCallbackHandler to supply
each Binding to.
public List listBindings(String base,
NameClassPairMapper mapper)
LdapOperationsbase. Pass all the found Binding objects to the
supplied NameClassPairMapper and return all the returned
values as a List.
listBindings in interface LdapOperationsbase - The base DN where the list should be performed.mapper - The NameClassPairMapper to supply each
Binding to.
List containing the Objects returned from the
Mapper.
public List listBindings(Name base,
NameClassPairMapper mapper)
LdapOperationsbase. Pass all the found Binding objects to the
supplied NameClassPairMapper and return all the returned
values as a List.
listBindings in interface LdapOperationsbase - The base DN where the list should be performed.mapper - The NameClassPairMapper to supply each
Binding to.
List containing the Objects returned from the
Mapper.public List listBindings(String base)
LdapOperationsbase.
listBindings in interface LdapOperationsbase - The base DN where the list should be performed.
List containing the names of all the contexts
bound to base.public List listBindings(Name base)
LdapOperationsbase.
listBindings in interface LdapOperationsbase - The base DN where the list should be performed.
List containing the names of all the contexts
bound to base.
public List listBindings(String base,
ContextMapper mapper)
LdapOperationsbase. The Object returned in each Binding is
supplied to the specified ContextMapper.
listBindings in interface LdapOperationsbase - The base DN where the list should be performed.mapper - The ContextMapper to use for mapping the found
object.
List containing all entries received from the
ContextMapper.
public List listBindings(Name base,
ContextMapper mapper)
LdapOperationsbase. The Object returned in each Binding is
supplied to the specified ContextMapper.
listBindings in interface LdapOperationsbase - The base DN where the list should be performed.mapper - The ContextMapper to use for mapping the found
object.
List containing all entries received from the
ContextMapper.public Object executeReadOnly(ContextExecutor ce)
LdapOperationsDirContext,
translating any Exceptions and closing the context afterwards. This
method is not intended for searches; use
LdapOperations.search(SearchExecutor, NameClassPairCallbackHandler) or any of
the overloaded search methods for this.
executeReadOnly in interface LdapOperationsce - The ContextExecutor to which the actual operation
on the DirContext will be delegated.
LdapOperations.search(SearchExecutor, NameClassPairCallbackHandler),
LdapOperations.search(Name, String, AttributesMapper),
LdapOperations.search(Name, String, ContextMapper)public Object executeReadWrite(ContextExecutor ce)
LdapOperationsDirContext,
translating any exceptions and closing the context afterwards. This
method is intended only for very particular cases, where there is no
suitable method in this interface to use.
executeReadWrite in interface LdapOperationsce - The ContextExecutor to which the actual operation
on the DirContext will be delegated.
LdapOperations.bind(Name, Object, Attributes),
LdapOperations.unbind(Name),
LdapOperations.rebind(Name, Object, Attributes),
LdapOperations.rename(Name, Name),
LdapOperations.modifyAttributes(Name, ModificationItem[])public Object lookup(Name dn)
LdapOperationsDirContextAdapter, unless the DirObjectFactory
has been modified in the ContextSource.
lookup in interface LdapOperationsdn - The distinguished name of the object to find.
DirContextAdapter instance.LdapOperations.lookupContext(Name),
AbstractContextSource.setDirObjectFactory(Class)public Object lookup(String dn)
LdapOperationsDirContextAdapter, unless the DirObjectFactory
has been modified in the ContextSource.
lookup in interface LdapOperationsdn - The distinguished name of the object to find.
DirContextAdapter instance.LdapOperations.lookupContext(String),
AbstractContextSource.setDirObjectFactory(Class)
public Object lookup(Name dn,
AttributesMapper mapper)
LdapOperationsAttributesMapper.
lookup in interface LdapOperationsdn - The distinguished name to find.mapper - The AttributesMapper to use for mapping the
found object.
public Object lookup(String dn,
AttributesMapper mapper)
LdapOperationsAttributesMapper.
lookup in interface LdapOperationsdn - The distinguished name to find.mapper - The AttributesMapper to use for mapping the
found object.
public Object lookup(Name dn,
ContextMapper mapper)
LdapOperationsContextMapper.
lookup in interface LdapOperationsdn - The distinguished name to find.mapper - The ContextMapper to use for mapping the found
object.
public Object lookup(String dn,
ContextMapper mapper)
LdapOperationsContextMapper.
lookup in interface LdapOperationsdn - The distinguished name to find.mapper - The ContextMapper to use for mapping the found
object.
public Object lookup(Name dn,
String[] attributes,
AttributesMapper mapper)
LdapOperationsAttributesMapper.
lookup in interface LdapOperationsdn - The distinguished name to find.attributes - The names of the attributes to pass to the mapper.mapper - The AttributesMapper to use for mapping the
found object.
public Object lookup(String dn,
String[] attributes,
AttributesMapper mapper)
LdapOperationsAttributesMapper.
lookup in interface LdapOperationsdn - The distinguished name to find.attributes - The names of the attributes to pass to the mapper.mapper - The AttributesMapper to use for mapping the
found object.
public Object lookup(Name dn,
String[] attributes,
ContextMapper mapper)
LdapOperationsContextMapper.
lookup in interface LdapOperationsdn - The distinguished name to find.attributes - The names of the attributes to pass to the mapper.mapper - The ContextMapper to use for mapping the found
object.
public Object lookup(String dn,
String[] attributes,
ContextMapper mapper)
LdapOperationsContextMapper.
lookup in interface LdapOperationsdn - The distinguished name to find.attributes - The names of the attributes to pass to the mapper.mapper - The ContextMapper to use for mapping the found
object.
public void modifyAttributes(Name dn,
ModificationItem[] mods)
LdapOperationsModificationItems.
modifyAttributes in interface LdapOperationsdn - The distinguished name of the node to modify.mods - The modifications to perform.LdapOperations.modifyAttributes(DirContextOperations)
public void modifyAttributes(String dn,
ModificationItem[] mods)
LdapOperationsModificationItems.
modifyAttributes in interface LdapOperationsdn - The distinguished name of the node to modify.mods - The modifications to perform.LdapOperations.modifyAttributes(DirContextOperations)
public void bind(Name dn,
Object obj,
Attributes attributes)
LdapOperationsobj parameter or the
attributes parameter (or both). One of these parameters may
be null but not both.
bind in interface LdapOperationsdn - 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.DirContextAdapter
public void bind(String dn,
Object obj,
Attributes attributes)
LdapOperationsobj parameter or the
attributes parameter (or both). One of these parameters may
be null but not both.
bind in interface LdapOperationsdn - 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.DirContextAdapterpublic void unbind(Name dn)
LdapOperationsLdapOperations.unbind(Name, boolean) in stead.
unbind in interface LdapOperationsdn - The distinguished name of the entry to remove.public void unbind(String dn)
LdapOperationsLdapOperations.unbind(Name, boolean) in stead.
unbind in interface LdapOperationsdn - The distinguished name to unbind.
public void unbind(Name dn,
boolean recursive)
LdapOperations
unbind in interface LdapOperationsdn - The distinguished name to unbind.recursive - Whether to unbind all subcontexts as well. If this
parameter is false and the entry has children, the operation
will fail.
public void unbind(String dn,
boolean recursive)
LdapOperations
unbind in interface LdapOperationsdn - The distinguished name to unbind.recursive - Whether to unbind all subcontexts as well. If this
parameter is false and the entry has children, the operation
will fail.
protected void deleteRecursively(DirContext ctx,
DistinguishedName name)
ctx - The context to use for deleting.name - The starting point to delete recursively.
NamingException - if any error occurs
public void rebind(Name dn,
Object obj,
Attributes attributes)
LdapOperationsobj parameter
or the attributes parameter (or both). One of these
parameters may be null but not both. This method assumes
that the specified context already exists - if not it will fail.
rebind in interface LdapOperationsdn - The distinguished name to rebind.obj - The object to bind to the DN, may be null.
Typically a DirContext implementation.attributes - The attributes to bind, may be null.DirContextAdapter
public void rebind(String dn,
Object obj,
Attributes attributes)
LdapOperationsobj parameter
or the attributes parameter (or both). One of these
parameters may be null but not both. This method assumes
that the specified context already exists - if not it will fail.
rebind in interface LdapOperationsdn - The distinguished name to rebind.obj - The object to bind to the DN, may be null.
Typically a DirContext implementation.attributes - The attributes to bind, may be null.DirContextAdapter
public void rename(Name oldDn,
Name newDn)
LdapOperations
rename in interface LdapOperationsoldDn - The distinguished name of the entry to move; may not be
null or empty.newDn - The distinguished name where the entry should be moved; may
not be null or empty.
public void rename(String oldDn,
String newDn)
LdapOperations
rename in interface LdapOperationsoldDn - The distinguished name of the entry to move; may not be
null or empty.newDn - The distinguished name where the entry should be moved; may
not be null or empty.
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface InitializingBeanExceptionpublic DirContextOperations lookupContext(Name dn)
LdapOperationsDirContextOperations.
lookupContext in interface LdapOperationsdn - The distinguished name of the object to find.
DirContextOperations.LdapOperations.lookup(Name),
LdapOperations.modifyAttributes(DirContextOperations)public DirContextOperations lookupContext(String dn)
LdapOperationsDirContextOperations.
lookupContext in interface LdapOperationsdn - The distinguished name of the object to find.
DirContextOperations.LdapOperations.lookup(String),
LdapOperations.modifyAttributes(DirContextOperations)public void modifyAttributes(DirContextOperations ctx)
LdapOperationsDirContextOperations instance. The DN to update will be the DN of
the DirContextOperationsinstance, and the
ModificationItem array is retrieved from the
DirContextOperations instance using a call to
AttributeModificationsAware.getModificationItems(). NB:
The supplied instance needs to have been properly initialized; this means
that if it hasn't been received from a lookup operation, its
DN needs to be initialized and it must have been put in update mode (
DirContextAdapter.setUpdateMode(boolean)).
Typical use of this method would be as follows:
public void update(Person person) {
DirContextOperations ctx = ldapOperations.lookupContext(person.getDn());
ctx.setAttributeValue("description", person.getDescription());
ctx.setAttributeValue("telephoneNumber", person.getPhone());
// More modifications here
ldapOperations.modifyAttributes(ctx);
}
modifyAttributes in interface LdapOperationsctx - the DirContextOperations instance to use in the update.LdapOperations.lookupContext(Name),
DirContextAdapterpublic void bind(DirContextOperations ctx)
LdapOperationsctxin will be bound to the DN set on ctx.
Example:
DirContextOperations ctx = new DirContextAdapter(dn);
ctx.setAttributeValue("cn", "john doe");
ctx.setAttributeValue("description", "some description");
//More initialization here.
ldapTemplate.bind(ctx);
bind in interface LdapOperationsctx - the context to bindpublic void rebind(DirContextOperations ctx)
LdapOperationsctx parameter. This
method assumes that the specified context already exists - if not it will
fail. The entry will be bound to the DN set on ctx.
Example:
DirContextOperations ctx = new DirContextAdapter(dn);
ctx.setAttributeValue("cn", "john doe");
ctx.setAttributeValue("description", "some description");
//More initialization here.
ldapTemplate.rebind(ctx);
rebind in interface LdapOperationsctx - the context to rebind
public boolean authenticate(Name base,
String filter,
String password)
LdapOperationsContextSource.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);
authenticate in interface LdapOperationsbase - 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(String base,
String filter,
String password)
LdapOperationsContextSource.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);
authenticate in interface LdapOperationsbase - 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(String base,
String filter,
String password,
AuthenticatedLdapEntryContextCallback callback)
LdapOperationsContextSource.getContext(String, String), thus authenticating the
entry. The resulting DirContext instance is then used as input to the
supplied AuthenticatedLdapEntryContextCallback to perform any
additional LDAP operations against the authenticated DirContext.
authenticate in interface LdapOperationsbase - 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.callback - the callback to that will be called to perform operations
on the DirContext authenticated with the found user.
true if the authentication was successful,
false otherwise.LdapOperations.authenticate(String, String, String)
public boolean authenticate(Name base,
String filter,
String password,
AuthenticatedLdapEntryContextCallback callback)
LdapOperationsContextSource.getContext(String, String), thus authenticating the
entry. The resulting DirContext instance is then used as input to the
supplied AuthenticatedLdapEntryContextCallback to perform any
additional LDAP operations against the authenticated DirContext.
authenticate in interface LdapOperationsbase - 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.callback - the callback to that will be called to perform operations
on the DirContext authenticated with the found user.
true if the authentication was successful,
false otherwise.LdapOperations.authenticate(Name, String, String)
public boolean authenticate(String base,
String filter,
String password,
AuthenticationErrorCallback errorCallback)
LdapOperationsContextSource.getContext(String, String), thus authenticating the
entry. If an exception is caught, the same exception is passed on to the given
AuthenticationErrorCallback. This enables the caller to provide a
callback that, for example, collects the exception for later processing.
authenticate in interface LdapOperationsbase - 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.errorCallback - the callback that will be called if an exception is caught.
true if the authentication was successful,
false otherwise.LdapOperations.authenticate(String, String, String, AuthenticatedLdapEntryContextCallback, AuthenticationErrorCallback)
public boolean authenticate(Name base,
String filter,
String password,
AuthenticationErrorCallback errorCallback)
LdapOperationsContextSource.getContext(String, String), thus authenticating the
entry. If an exception is caught, the same exception is passed on to the given
AuthenticationErrorCallback. This enables the caller to provide a
callback that, for example, collects the exception for later processing.
authenticate in interface LdapOperationsbase - 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.errorCallback - the callback that will be called if an exception is caught.
true if the authentication was successful,
false otherwise.LdapOperations.authenticate(Name, String, String, AuthenticatedLdapEntryContextCallback, AuthenticationErrorCallback)
public boolean authenticate(String base,
String filter,
String password,
AuthenticatedLdapEntryContextCallback callback,
AuthenticationErrorCallback errorCallback)
LdapOperationsContextSource.getContext(String, String), thus authenticating the
entry. The resulting DirContext instance is then used as input to the
supplied AuthenticatedLdapEntryContextCallback to perform any
additional LDAP operations against the authenticated DirContext. If an
exception is caught, the same exception is passed on to the given
AuthenticationErrorCallback. This enables the caller to provide a
callback that, for example, collects the exception for later processing.
authenticate in interface LdapOperationsbase - 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.callback - the callback that will be called to perform operations
on the DirContext authenticated with the found user.errorCallback - the callback that will be called if an exception is caught.
true if the authentication was successful,
false otherwise.LdapOperations.authenticate(String, String, String, AuthenticatedLdapEntryContextCallback)
public boolean authenticate(Name base,
String filter,
String password,
AuthenticatedLdapEntryContextCallback callback,
AuthenticationErrorCallback errorCallback)
LdapOperationsContextSource.getContext(String, String), thus authenticating the
entry. The resulting DirContext instance is then used as input to the
supplied AuthenticatedLdapEntryContextCallback to perform any
additional LDAP operations against the authenticated DirContext. If an
exception is caught, the same exception is passed on to the given
AuthenticationErrorCallback. This enables the caller to provide a
callback that, for example, collects the exception for later processing.
authenticate in interface LdapOperationsbase - 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.callback - the callback that will be called to perform operations
on the DirContext authenticated with the found user.errorCallback - the callback that will be called if an exception is caught.
true if the authentication was successful,
false otherwise.LdapOperations.authenticate(Name, String, String, AuthenticatedLdapEntryContextCallback)
public Object searchForObject(Name base,
String filter,
ContextMapper mapper)
LdapOperationsIncorrectResultSizeDataAccessException is thrown.
searchForObject in interface LdapOperationsbase - the DN to use as the base of the search.filter - the search filter.mapper - the mapper to use for the search.
public Object searchForObject(String base,
String filter,
ContextMapper mapper)
LdapOperationsIncorrectResultSizeDataAccessException is thrown.
searchForObject in interface LdapOperationsbase - the DN to use as the base of the search.filter - the search filter.mapper - the mapper to use for the search.
|
Spring LDAP Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||