Class LDAPPersistSearchControl
- All Implemented Interfaces:
Serializable
,Cloneable
LDAPEntryChangeControl
object.
To use persistent searching for change notification, you create a "persistent search" control that specifies the types of changes that you want to track. You include the control in a search request. If an entry in the directory is changed, the server determines if the entry matches the search criteria in your request and if the change is the type of change that you are tracking. If both of these are true, the server sends the entry to your client.
The server can also include an "entry change notification" control with the entry. (The OID for this control is 2.16.840.1.113730.3.4.7.) This control contains additional information about the change made to the entry, including the type of change made, the change number (which corresponds to an item in the server's change log, if the server supports a change log), and, if the entry was renamed, the old DN of the entry.
When constructing an LDAPPersistSearchControl
object,
you can specify the following information:
- the type of change you want to track (added, modified, deleted, or renamed entries)
- a preference indicating whether or not you want the server to return all entries that initially matched the search criteria (rather than only the entries that change)
- a preference indicating whether or not you want entry change notification controls included with every entry returned by the server
For example:
... LDAPConnection ld = new LDAPConnection(); try { // Connect to server. ld.connect( 3, hostname, portnumber, "", "" ); // Create a persistent search control. int op = LDAPPersistSearchControl.ADD | LDAPPersistSearchControl.MODIFY | LDAPPersistSearchControl.DELETE | LDAPPersistSearchControl.MODDN; boolean changesOnly = true; boolean returnControls = true; boolean isCritical = true; LDAPPersistSearchControl persistCtrl = new LDAPPersistSearchControl( op, changesOnly, returnControls, isCritical ); // Set the search constraints to use that control. LDAPSearchConstraints cons = ld.getSearchConstraints(); cons.setBatchSize( 1 ); cons.setServerControls( persistCtrl ); // Start the persistent search. LDAPSearchResults res = ld.search( "o=Airius.com", LDAPv3.SCOPE_SUB, "(cn=Barbara*)", null, false, cons ); // Loop through the incoming results. while ( res.hasMoreElements() ) { ... } ... }
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Change type specifying that you want to track additions of new entries to the directory.static final int
Change type specifying that you want to track removals of entries from the directory.static final int
Change type specifying that you want to track modifications of the DNs of entries in the directory.static final int
Change type specifying that you want to track modifications of entries in the directory.static final String
Fields inherited from class netscape.ldap.LDAPControl
m_critical, m_value, MANAGEDSAIT, PWEXPIRED, PWEXPIRING
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorLDAPPersistSearchControl
(int changeTypes, boolean changesOnly, boolean returnControls, boolean isCritical) Constructs anLDAPPersistSearchControl
object that specifies a persistent search. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Indicates whether you want the server to send any existing entries that already match the search criteria or only the entries that have changed.int
Gets the change types monitored by this control.boolean
Indicates whether or not the server includes an "entry change notification" control with each entry it sends back to the client during the persistent search.parseResponse
(byte[] c) Deprecated.LDAPEntryChangeControl controls are now automatically instantiated.static LDAPEntryChangeControl
parseResponse
(LDAPControl[] controls) Deprecated.LDAPEntryChangeControl controls are now automatically instantiated.void
setChangesOnly
(boolean changesOnly) Specifies whether you want the server to send any existing entries that already match the search criteria or only the entries that have changed.void
setChangeTypes
(int types) Sets the change types that you want monitored by this control.void
setReturnControls
(boolean returnControls) Specifies whether you want the server to include an "entry change notification" control with each entry it sends back to the client during the persistent search.toString()
Return a string representation of the control for debuggingMethods inherited from class netscape.ldap.LDAPControl
clone, createControl, flattenBER, getID, getValue, isCritical, lookupControlClass, newInstance, register
-
Field Details
-
ADD
public static final int ADDChange type specifying that you want to track additions of new entries to the directory. You can either specify this change type when constructing anLDAPPersistSearchControl
or by using thesetChangeTypes
method. -
DELETE
public static final int DELETEChange type specifying that you want to track removals of entries from the directory. You can either specify this change type when constructing anLDAPPersistSearchControl
or by using thesetChangeTypes
method. -
MODIFY
public static final int MODIFYChange type specifying that you want to track modifications of entries in the directory. You can either specify this change type when constructing anLDAPPersistSearchControl
or by using thesetChangeTypes
method. -
MODDN
public static final int MODDNChange type specifying that you want to track modifications of the DNs of entries in the directory. You can either specify this change type when constructing anLDAPPersistSearchControl
or by using thesetChangeTypes
method. -
PERSISTENTSEARCH
- See Also:
-
-
Constructor Details
-
LDAPPersistSearchControl
public LDAPPersistSearchControl()Default constructor -
LDAPPersistSearchControl
public LDAPPersistSearchControl(int changeTypes, boolean changesOnly, boolean returnControls, boolean isCritical) Constructs anLDAPPersistSearchControl
object that specifies a persistent search.- Parameters:
changeTypes
- the change types to monitor. You can perform a bitwise OR on any of the following values and specify the result as the change types:LDAPPersistSearchControl.ADD
(to track new entries added to the directory)LDAPPersistSearchControl.DELETE
(to track entries removed from the directory)LDAPPersistSearchControl.MODIFY
(to track entries that have been modified)LDAPPersistSearchControl.MODDN
(to track entries that have been renamed)
changesOnly
-true
if you do not want the server to return all existing entries in the directory that match the search criteria. (Use this if you just want the changed entries to be returned.)returnControls
-true
if you want the server to return entry change controls with each entry in the search resultsisCritical
-true
if this control is critical to the search operation. (If the server does not support this control, you may not want the server to perform the search at all.)- See Also:
-
-
Method Details
-
getChangeTypes
public int getChangeTypes()Gets the change types monitored by this control.- Returns:
- integer representing the change types to monitor.
This value can be the bitwise OR of
ADD, DELETE, MODIFY,
and/orMODDN
. If the change type is unknown, this method returns -1. - See Also:
-
getChangesOnly
public boolean getChangesOnly()Indicates whether you want the server to send any existing entries that already match the search criteria or only the entries that have changed.- Returns:
- if
true
, the server returns only the entries that have changed. Iffalse
, the server also returns any existing entries that match the search criteria but have not changed. - See Also:
-
getReturnControls
public boolean getReturnControls()Indicates whether or not the server includes an "entry change notification" control with each entry it sends back to the client during the persistent search.- Returns:
true
if the server includes "entry change notification" controls with the entries it sends during the persistent search.- See Also:
-
setChangeTypes
public void setChangeTypes(int types) Sets the change types that you want monitored by this control.- Parameters:
types
- integer representing the change types to monitor This value can be the bitwise OR ofADD, DELETE, MODIFY,
and/orMODDN
.- See Also:
-
setChangesOnly
public void setChangesOnly(boolean changesOnly) Specifies whether you want the server to send any existing entries that already match the search criteria or only the entries that have changed.- Parameters:
changesOnly
- iftrue
, the server returns only the entries that have changed. Iffalse
, the server also returns any existing entries that match the search criteria but have not changed.- See Also:
-
setReturnControls
public void setReturnControls(boolean returnControls) Specifies whether you want the server to include an "entry change notification" control with each entry it sends back to the client during the persistent search.- Parameters:
returnControls
- iftrue
, the server includes "entry change notification" controls with the entries it sends during the persistent search- See Also:
-
parseResponse
Deprecated.LDAPEntryChangeControl controls are now automatically instantiated.Takes an input byte array and extracts the ber elements, assigning them to appropriate fields in the entry change control.- Parameters:
c
- byte array that contains BER elements- Returns:
- the entry change control.
-
parseResponse
Deprecated.LDAPEntryChangeControl controls are now automatically instantiated.Returns an "entry change notification" control if the control is in the specified array of controls. Use this method to retrieve an "entry change notification" control included with an entry sent by the server.You can get the controls returned by the server by using the
getResponseControls
method of theLDAPConnection
class.For example:
- Parameters:
controls
- an array ofLDAPControl
objects, representing the controls returned by the server with an entry. To get these controls, use thegetResponseControls
method of theLDAPConnection
class.- Returns:
- an
LDAPEntryChangeControl
object representing the entry change control sent by the server. If no entry change control was sent, this method returns null. - See Also:
-
toString
Description copied from class:LDAPControl
Return a string representation of the control for debugging- Overrides:
toString
in classLDAPControl
- Returns:
- a string representation of the control.
-