Package org.ldaptive.ad.control.util
Class DirSyncClient
- java.lang.Object
-
- org.ldaptive.ad.control.util.DirSyncClient
-
public class DirSyncClient extends Object
Client that simplifies using the active directory dir sync control.
-
-
Field Summary
Fields Modifier and Type Field Description private DirSyncControl.Flag[]
dirSyncFlags
DirSync flags.private ExtendedDnControl.Flag
extendedDnFlag
ExtendedDn flags.private ConnectionFactory
factory
Connection factory to get a connection from.protected Logger
logger
Logger for this class.private int
maxAttributeCount
Maximum attribute count.
-
Constructor Summary
Constructors Constructor Description DirSyncClient(ConnectionFactory cf)
Creates a new dir sync client.DirSyncClient(ConnectionFactory cf, DirSyncControl.Flag[] dsFlags)
Creates a new dir sync client.DirSyncClient(ConnectionFactory cf, DirSyncControl.Flag[] dsFlags, int count)
Creates a new dir sync client.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private RequestControl[]
createRequestControls(byte[] cookie)
Returns the list of request controls configured for this client.SearchResponse
execute(SearchRequest request)
Performs a search operation with theDirSyncControl
.SearchResponse
execute(SearchRequest request, CookieManager manager)
Performs a search operation with theDirSyncControl
.SearchResponse
execute(SearchRequest request, SearchResponse result)
Performs a search operation with theDirSyncControl
.SearchResponse
executeToCompletion(SearchRequest request)
Invokesexecute(SearchRequest, CookieManager)
with aDefaultCookieManager
.SearchResponse
executeToCompletion(SearchRequest request, CookieManager manager)
Performs a search operation with theDirSyncControl
.protected byte[]
getDirSyncCookie(SearchResponse result)
Returns the dir sync cookie in the supplied response or null if no cookie exists.protected long
getDirSyncFlags(SearchResponse result)
Returns the dir sync flags in the supplied response or -1 if no flags exists.ExtendedDnControl.Flag
getExtendedDnFlag()
Returns the flag that is used on the extended dn control.boolean
hasMore(SearchResponse result)
Returns whetherexecute(SearchRequest, SearchResponse)
can be invoked again.void
setExtendedDnFlag(ExtendedDnControl.Flag flag)
Sets the flag to use on the extended dn control.
-
-
-
Field Detail
-
logger
protected final Logger logger
Logger for this class.
-
factory
private final ConnectionFactory factory
Connection factory to get a connection from.
-
dirSyncFlags
private final DirSyncControl.Flag[] dirSyncFlags
DirSync flags.
-
maxAttributeCount
private final int maxAttributeCount
Maximum attribute count.
-
extendedDnFlag
private ExtendedDnControl.Flag extendedDnFlag
ExtendedDn flags.
-
-
Constructor Detail
-
DirSyncClient
public DirSyncClient(ConnectionFactory cf)
Creates a new dir sync client.- Parameters:
cf
- to get a connection from
-
DirSyncClient
public DirSyncClient(ConnectionFactory cf, DirSyncControl.Flag[] dsFlags)
Creates a new dir sync client.- Parameters:
cf
- to get a connection fromdsFlags
- to set on the dir sync control
-
DirSyncClient
public DirSyncClient(ConnectionFactory cf, DirSyncControl.Flag[] dsFlags, int count)
Creates a new dir sync client.- Parameters:
cf
- to get a connection fromdsFlags
- to set on the dir sync controlcount
- max attribute count
-
-
Method Detail
-
getExtendedDnFlag
public ExtendedDnControl.Flag getExtendedDnFlag()
Returns the flag that is used on the extended dn control.- Returns:
- extended dn control flag
-
setExtendedDnFlag
public void setExtendedDnFlag(ExtendedDnControl.Flag flag)
Sets the flag to use on the extended dn control.- Parameters:
flag
- to set on the extended dn control
-
execute
public SearchResponse execute(SearchRequest request) throws LdapException
Performs a search operation with theDirSyncControl
. The supplied request is modified in the following way:- Parameters:
request
- search request to execute- Returns:
- search operation response
- Throws:
LdapException
- if the search fails
-
execute
public SearchResponse execute(SearchRequest request, SearchResponse result) throws LdapException
Performs a search operation with theDirSyncControl
. The supplied request is modified in the following way:AbstractRequestMessage.setControls( org.ldaptive.control.RequestControl...)
is invoked withDirSyncControl
,ShowDeletedControl
, andExtendedDnControl
The cookie is extracted from the supplied response and replayed in the request.
- Parameters:
request
- search request to executeresult
- of a previous dir sync operation- Returns:
- search operation response
- Throws:
IllegalArgumentException
- if the response does not contain a dir sync cookieLdapException
- if the search fails
-
execute
public SearchResponse execute(SearchRequest request, CookieManager manager) throws LdapException
Performs a search operation with theDirSyncControl
. The supplied request is modified in the following way:AbstractRequestMessage.setControls( org.ldaptive.control.RequestControl...)
is invoked withDirSyncControl
,ShowDeletedControl
, andExtendedDnControl
The cookie used in the request is read from the cookie manager and written to the cookie manager after a successful search, if the response contains a cookie.
- Parameters:
request
- search request to executemanager
- for reading and writing cookies- Returns:
- search operation response
- Throws:
LdapException
- if the search fails
-
hasMore
public boolean hasMore(SearchResponse result)
Returns whetherexecute(SearchRequest, SearchResponse)
can be invoked again.- Parameters:
result
- of a previous dir sync operation- Returns:
- whether more dir sync results can be retrieved from the server
-
executeToCompletion
public SearchResponse executeToCompletion(SearchRequest request) throws LdapException
Invokesexecute(SearchRequest, CookieManager)
with aDefaultCookieManager
.- Parameters:
request
- search request to execute- Returns:
- search operation response of the last dir sync operation
- Throws:
LdapException
- if the search fails
-
executeToCompletion
public SearchResponse executeToCompletion(SearchRequest request, CookieManager manager) throws LdapException
Performs a search operation with theDirSyncControl
. The supplied request is modified in the following way:AbstractRequestMessage.setControls( org.ldaptive.control.RequestControl...)
is invoked withDirSyncControl
,ShowDeletedControl
, andExtendedDnControl
This method will continue to execute search operations until all dir sync search results have been retrieved from the server. The returned response contains the response data of the last dir sync operation plus the entries and references returned by all previous search operations.
The cookie used for each request is read from the cookie manager and written to the cookie manager after a successful search, if the response contains a cookie.
- Parameters:
request
- search request to executemanager
- for reading and writing cookies- Returns:
- search operation response of the last dir sync operation
- Throws:
LdapException
- if the search fails
-
getDirSyncFlags
protected long getDirSyncFlags(SearchResponse result)
Returns the dir sync flags in the supplied response or -1 if no flags exists.- Parameters:
result
- of a previous dir sync operation- Returns:
- dir sync flags or -1
-
getDirSyncCookie
protected byte[] getDirSyncCookie(SearchResponse result)
Returns the dir sync cookie in the supplied response or null if no cookie exists.- Parameters:
result
- of a previous dir sync operation- Returns:
- dir sync cookie or null
-
createRequestControls
private RequestControl[] createRequestControls(byte[] cookie)
Returns the list of request controls configured for this client.- Parameters:
cookie
- to add to the dir sync control or null- Returns:
- search request controls
-
-