Interface LdapConnectionOperations
-
- All Known Implementing Classes:
LdapConnectionTemplate
public interface LdapConnectionOperations
Specifies the set of operations available onLdapConnectionTemplate
. This interface can be useful for unit testing in order to stub out methods.- Author:
- Apache Directory Project
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description AddResponse
add(AddRequest addRequest)
Adds an entry specified by an AddRequest to the LDAP server.AddResponse
add(Dn dn, Attribute... attributes)
Adds an entry specified by a Dn and an array of Attribute's to the LDAP server.AddResponse
add(Dn dn, RequestBuilder<AddRequest> requestBuilder)
Adds an entry specified by a Dn, to be filled out by a RequestBuilder, to the LDAP server.PasswordWarning
authenticate(String baseDn, String filter, SearchScope scope, char[] password)
Attempts to authenticate the supplied credentials against the first entry found matching the search criteria.PasswordWarning
authenticate(SearchRequest searchRequest, char[] password)
Attempts to authenticate the supplied credentials against the first entry found matching the search criteria.PasswordWarning
authenticate(Dn userDn, char[] password)
Attempts to authenticate the supplied credentials.PasswordWarning
authenticate(Dn baseDn, String filter, SearchScope scope, char[] password)
Attempts to authenticate the supplied credentials against the first entry found matching the search criteria.DeleteResponse
delete(DeleteRequest deleteRequest)
Deletes an entry specified by a DeleteRequest from the LDAP server.DeleteResponse
delete(Dn dn)
Deletes an entry specified by Dn from the LDAP server.DeleteResponse
delete(Dn dn, RequestBuilder<DeleteRequest> requestBuilder)
Deletes an entry specified by Dn, and whose request is configured by a RequestBuilder, from the LDAP server.<T> T
execute(ConnectionCallback<T> connectionCallback)
Executes theconnectionCallback
, supplying it a managed connection.<T> T
lookup(Dn dn, String[] attributes, EntryMapper<T> entryMapper)
Performs a lookup, requestingattributes
, and supplies the matching entry to theentryMapper
.<T> T
lookup(Dn dn, EntryMapper<T> entryMapper)
Performs a lookup, and supplies the matching entry to theentryMapper
.ModifyResponse
modify(ModifyRequest modifyRequest)
Modifies an entry specified by a ModifyRequest on the LDAP server.ModifyResponse
modify(Dn dn, RequestBuilder<ModifyRequest> requestBuilder)
Modifies an entry specified by Dn, and whose request is configured by a RequestBuilder, on the LDAP server.void
modifyPassword(Dn userDn, char[] newPassword)
Modifies the password foruserDn
tonewPassword
using the admin account.void
modifyPassword(Dn userDn, char[] oldPassword, char[] newPassword)
Modifies the password foruserDn
fromoldPassword
tonewPassword
.void
modifyPassword(Dn userDn, char[] oldPassword, char[] newPassword, boolean asAdmin)
Modifies the password foruserDn
fromoldPassword
tonewPassword
, optionally using an admin account.<T extends ResultResponse>
TresponseOrException(T response)
Checks the supplied response for its result code, and if not ResultCodeEnum#SUCCESS, an exception is thrown.<T> List<T>
search(String baseDn, String filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.<T> List<T>
search(String baseDn, String filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
.<T> List<T>
search(String baseDn, FilterBuilder filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.<T> List<T>
search(String baseDn, FilterBuilder filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
.<T> List<T>
search(SearchRequest searchRequest, EntryMapper<T> entryMapper)
Searches for the entries matching the suppliedsearchRequest
, feeding the result into theentryMapper
.<T> List<T>
search(Dn baseDn, String filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.<T> List<T>
search(Dn baseDn, String filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
.<T> List<T>
search(Dn baseDn, FilterBuilder filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.<T> List<T>
search(Dn baseDn, FilterBuilder filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
.<T> T
searchFirst(String baseDn, String filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.<T> T
searchFirst(String baseDn, String filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
.<T> T
searchFirst(String baseDn, FilterBuilder filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.<T> T
searchFirst(String baseDn, FilterBuilder filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
.<T> T
searchFirst(SearchRequest searchRequest, EntryMapper<T> entryMapper)
Searches for the first entry matching the suppliedsearchRequest
, feeding the result into theentryMapper
.<T> T
searchFirst(Dn baseDn, String filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.<T> T
searchFirst(Dn baseDn, String filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
.<T> T
searchFirst(Dn baseDn, FilterBuilder filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.<T> T
searchFirst(Dn baseDn, FilterBuilder filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
.
-
-
-
Method Detail
-
add
AddResponse add(AddRequest addRequest)
Adds an entry specified by an AddRequest to the LDAP server.- Parameters:
addRequest
- The request- Returns:
- An AddResponse
-
add
AddResponse add(Dn dn, Attribute... attributes)
Adds an entry specified by a Dn and an array of Attribute's to the LDAP server.- Parameters:
dn
- The distinguished name of the new entryattributes
- The attributes of the new entry- Returns:
- An AddResponse
-
add
AddResponse add(Dn dn, RequestBuilder<AddRequest> requestBuilder)
Adds an entry specified by a Dn, to be filled out by a RequestBuilder, to the LDAP server.- Parameters:
dn
- The distinguished name of the new entryrequestBuilder
- The request builder- Returns:
- An AddResponse
-
authenticate
PasswordWarning authenticate(String baseDn, String filter, SearchScope scope, char[] password) throws PasswordException
Attempts to authenticate the supplied credentials against the first entry found matching the search criteria. If authentication fails, a PasswordException is thrown. If successful, the response is checked for warnings, and if present, a PasswordWarning is returned. Otherwise, null is returned.- Parameters:
baseDn
- The base DN from which to start the search for the user to authenticatefilter
- The filter selecting the entriesscope
- The scope to look frompassword
- The password- Returns:
- A PasswordWarning or null
- Throws:
PasswordException
- If the authentication failed- See Also:
authenticate(Dn, char[])
,searchFirst(String, String, SearchScope, EntryMapper)
-
authenticate
PasswordWarning authenticate(Dn baseDn, String filter, SearchScope scope, char[] password) throws PasswordException
Attempts to authenticate the supplied credentials against the first entry found matching the search criteria. If authentication fails, a PasswordException is thrown. If successful, the response is checked for warnings, and if present, a PasswordWarning is returned. Otherwise, null is returned.- Parameters:
baseDn
- The base DN from which to start the search for the user to authenticatefilter
- The filter selecting the entriesscope
- The scope to look frompassword
- The password- Returns:
- A PasswordWarning or null
- Throws:
PasswordException
- If the authentication failed- See Also:
authenticate(Dn, char[])
,searchFirst(Dn, String, SearchScope, EntryMapper)
-
authenticate
PasswordWarning authenticate(SearchRequest searchRequest, char[] password) throws PasswordException
Attempts to authenticate the supplied credentials against the first entry found matching the search criteria. If authentication fails, a PasswordException is thrown. If successful, the response is checked for warnings, and if present, a PasswordWarning is returned. Otherwise, null is returned.- Parameters:
searchRequest
- The SearchRequst to use to find the user to authenticatepassword
- The password- Returns:
- A PasswordWarning or null
- Throws:
PasswordException
- If the authentication failed- See Also:
authenticate(Dn, char[])
,searchFirst(SearchRequest, EntryMapper)
-
authenticate
PasswordWarning authenticate(Dn userDn, char[] password) throws PasswordException
Attempts to authenticate the supplied credentials. If authentication fails, a PasswordException is thrown. If successful, the response is checked for warnings, and if present, a PasswordWarning is returned. Otherwise, null is returned.- Parameters:
userDn
- The distinguished name of the userpassword
- The password- Returns:
- A PasswordWarning or null
- Throws:
PasswordException
- If authentication fails
-
delete
DeleteResponse delete(DeleteRequest deleteRequest)
Deletes an entry specified by a DeleteRequest from the LDAP server.- Parameters:
deleteRequest
- The request- Returns:
- A DeleteResponse
-
delete
DeleteResponse delete(Dn dn)
Deletes an entry specified by Dn from the LDAP server.- Parameters:
dn
- The distinguished name of the entry- Returns:
- A DeleteResponse
-
delete
DeleteResponse delete(Dn dn, RequestBuilder<DeleteRequest> requestBuilder)
Deletes an entry specified by Dn, and whose request is configured by a RequestBuilder, from the LDAP server.- Parameters:
dn
- The distinguished name of the entryrequestBuilder
- The RequestBuilder- Returns:
- A DeleteResponse
-
execute
<T> T execute(ConnectionCallback<T> connectionCallback)
Executes theconnectionCallback
, supplying it a managed connection.- Type Parameters:
T
- The type of the mapped entry- Parameters:
connectionCallback
- The callback- Returns:
- Whatever the callback returns
-
lookup
<T> T lookup(Dn dn, EntryMapper<T> entryMapper)
Performs a lookup, and supplies the matching entry to theentryMapper
.- Type Parameters:
T
- The type of the mapped entry- Parameters:
dn
- The distinguished name of the entryentryMapper
- The mapper from entry to model object- Returns:
- Whatever the
entryMapper
returns
-
lookup
<T> T lookup(Dn dn, String[] attributes, EntryMapper<T> entryMapper)
Performs a lookup, requestingattributes
, and supplies the matching entry to theentryMapper
.- Type Parameters:
T
- The type of the mapped entry- Parameters:
dn
- The distinguished name of the entryattributes
- The attributes to be fetchedentryMapper
- The mapper from entry to model object- Returns:
- Whatever the
entryMapper
returns
-
modifyPassword
void modifyPassword(Dn userDn, char[] newPassword) throws PasswordException
Modifies the password foruserDn
tonewPassword
using the admin account.- Parameters:
userDn
- The DN of the entry we want to modify the pwassword fornewPassword
- The new password- Throws:
PasswordException
- If the password change failed- See Also:
modifyPassword(Dn, char[], char[], boolean)
-
modifyPassword
void modifyPassword(Dn userDn, char[] oldPassword, char[] newPassword) throws PasswordException
Modifies the password foruserDn
fromoldPassword
tonewPassword
.- Parameters:
userDn
- The DN of the entry we want to modify the pwassword foroldPassword
- The old passwordnewPassword
- The new password- Throws:
PasswordException
- If the password change failed- See Also:
modifyPassword(Dn, char[], char[], boolean)
-
modifyPassword
void modifyPassword(Dn userDn, char[] oldPassword, char[] newPassword, boolean asAdmin) throws PasswordException
Modifies the password foruserDn
fromoldPassword
tonewPassword
, optionally using an admin account. IfasAdmin
is true, then the operation is performed in admin context which meansoldPassword
is may benull
.- Parameters:
userDn
- The distinguished name of the useroldPassword
- The users old password (optional if asAdmin is true)newPassword
- The users new passwordasAdmin
- If true, execute in admin context- Throws:
PasswordException
- If the password modification fails
-
modify
ModifyResponse modify(ModifyRequest modifyRequest)
Modifies an entry specified by a ModifyRequest on the LDAP server.- Parameters:
modifyRequest
- The request- Returns:
- A ModifyResponse
-
modify
ModifyResponse modify(Dn dn, RequestBuilder<ModifyRequest> requestBuilder)
Modifies an entry specified by Dn, and whose request is configured by a RequestBuilder, on the LDAP server.- Parameters:
dn
- The distinguished name of the entryrequestBuilder
- The RequestBuilder- Returns:
- A ModifyResponse
-
responseOrException
<T extends ResultResponse> T responseOrException(T response)
Checks the supplied response for its result code, and if not ResultCodeEnum#SUCCESS, an exception is thrown. This method is intended to be used inline:template.responseOrException( template.delete( dn ) );
- Type Parameters:
T
- The type of response- Parameters:
response
- The response to check for success- Returns:
- The supplied
response
-
search
<T> List<T> search(String baseDn, FilterBuilder filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
search(SearchRequest, EntryMapper)
-
search
<T> List<T> search(String baseDn, String filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
search(SearchRequest, EntryMapper)
-
search
<T> List<T> search(Dn baseDn, FilterBuilder filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
search(SearchRequest, EntryMapper)
-
search
<T> List<T> search(Dn baseDn, String filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
search(SearchRequest, EntryMapper)
-
search
<T> List<T> search(String baseDn, FilterBuilder filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromattributes
- The list of AttributeType to returnentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
search(SearchRequest, EntryMapper)
-
search
<T> List<T> search(String baseDn, String filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromattributes
- The list of AttributeType to returnentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
search(SearchRequest, EntryMapper)
-
search
<T> List<T> search(Dn baseDn, FilterBuilder filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromattributes
- The list of AttributeType to returnentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
search(SearchRequest, EntryMapper)
-
search
<T> List<T> search(Dn baseDn, String filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the entries matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromattributes
- The list of AttributeType to returnentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
search(SearchRequest, EntryMapper)
-
search
<T> List<T> search(SearchRequest searchRequest, EntryMapper<T> entryMapper)
Searches for the entries matching the suppliedsearchRequest
, feeding the result into theentryMapper
.- Type Parameters:
T
- The type of the mapped entry- Parameters:
searchRequest
- The search requestentryMapper
- The mapper- Returns:
- The mapped entries
-
searchFirst
<T> T searchFirst(String baseDn, FilterBuilder filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
searchFirst(SearchRequest, EntryMapper)
-
searchFirst
<T> T searchFirst(String baseDn, String filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
searchFirst(SearchRequest, EntryMapper)
-
searchFirst
<T> T searchFirst(Dn baseDn, FilterBuilder filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
searchFirst(SearchRequest, EntryMapper)
-
searchFirst
<T> T searchFirst(Dn baseDn, String filter, SearchScope scope, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
searchFirst(SearchRequest, EntryMapper)
-
searchFirst
<T> T searchFirst(String baseDn, FilterBuilder filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromattributes
- The list of AttributeType to returnentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
searchFirst(SearchRequest, EntryMapper)
-
searchFirst
<T> T searchFirst(String baseDn, String filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromattributes
- The list of AttributeType to returnentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
searchFirst(SearchRequest, EntryMapper)
-
searchFirst
<T> T searchFirst(Dn baseDn, FilterBuilder filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromattributes
- The list of AttributeType to returnentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
searchFirst(SearchRequest, EntryMapper)
-
searchFirst
<T> T searchFirst(Dn baseDn, String filter, SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
Searches for the first entry matching the supplied criteria, feeding the result into theentryMapper
, querying only the requested attributes.- Type Parameters:
T
- The type of the mapped entry- Parameters:
baseDn
- The base DN from which to start the searchfilter
- The filter selecting the entriesscope
- The scope to look fromattributes
- The list of AttributeType to returnentryMapper
- The mapper- Returns:
- The mapped entries
- See Also:
searchFirst(SearchRequest, EntryMapper)
-
searchFirst
<T> T searchFirst(SearchRequest searchRequest, EntryMapper<T> entryMapper)
Searches for the first entry matching the suppliedsearchRequest
, feeding the result into theentryMapper
. This is basically the same assearch(SearchRequest, EntryMapper)
, but is optimized by modifying thesearchRequest
to set its size limit to 1. ThesearchRequest
is returned to its original size limit before this method returns (or throws an exception).- Type Parameters:
T
- The type of the mapped entry- Parameters:
searchRequest
- The search requestentryMapper
- The mapper- Returns:
- The mapped entry
-
-