Package com.unboundid.ldap.sdk
Class ModifyDNRequest
java.lang.Object
com.unboundid.ldap.sdk.LDAPRequest
com.unboundid.ldap.sdk.UpdatableLDAPRequest
com.unboundid.ldap.sdk.ModifyDNRequest
- All Implemented Interfaces:
ProtocolOp,ReadOnlyLDAPRequest,ReadOnlyModifyDNRequest,Serializable
@Mutable
@ThreadSafety(level=NOT_THREADSAFE)
public final class ModifyDNRequest
extends UpdatableLDAPRequest
implements ReadOnlyModifyDNRequest, ProtocolOp
This class implements the processing necessary to perform an LDAPv3 modify DN
operation, which can be used to rename and/or move an entry or subtree in the
directory. A modify DN request contains the DN of the target entry, the new
RDN to use for that entry, and a flag which indicates whether to remove the
current RDN attribute value(s) from the entry. It may optionally contain a
new superior DN, which will cause the entry to be moved below that new parent
entry.
Note that some directory servers may not support all possible uses of the modify DN operation. In particular, some servers may not support the use of a new superior DN, especially if it may cause the entry to be moved to a different database or another server. Also, some servers may not support renaming or moving non-leaf entries (i.e., entries that have one or more subordinates).
Note that some directory servers may not support all possible uses of the modify DN operation. In particular, some servers may not support the use of a new superior DN, especially if it may cause the entry to be moved to a different database or another server. Also, some servers may not support renaming or moving non-leaf entries (i.e., entries that have one or more subordinates).
ModifyDNRequest objects are mutable and therefore can be altered and
re-used for multiple requests. Note, however, that ModifyDNRequest
objects are not threadsafe and therefore a single ModifyDNRequest
object instance should not be used to process multiple requests at the same
time.
Example
The following example demonstrates the process for performing a modify DN operation. In this case, it will rename "ou=People,dc=example,dc=com" to "ou=Users,dc=example,dc=com". It will not move the entry below a new parent.
ModifyDNRequest modifyDNRequest =
new ModifyDNRequest("ou=People,dc=example,dc=com", "ou=Users", true);
LDAPResult modifyDNResult;
try
{
modifyDNResult = connection.modifyDN(modifyDNRequest);
// If we get here, the delete was successful.
}
catch (LDAPException le)
{
// The modify DN operation failed.
modifyDNResult = le.toLDAPResult();
ResultCode resultCode = le.getResultCode();
String errorMessageFromServer = le.getDiagnosticMessage();
}
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionModifyDNRequest(DN dn, RDN newRDN, boolean deleteOldRDN) Creates a new modify DN request that will rename the entry but will not move it below a new entry.ModifyDNRequest(DN dn, RDN newRDN, boolean deleteOldRDN, Control[] controls) Creates a new modify DN request that will rename the entry but will not move it below a new entry.ModifyDNRequest(DN dn, RDN newRDN, boolean deleteOldRDN, DN newSuperiorDN) Creates a new modify DN request that will rename the entry and will optionally move it below a new entry.ModifyDNRequest(DN dn, RDN newRDN, boolean deleteOldRDN, DN newSuperiorDN, Control[] controls) Creates a new modify DN request that will rename the entry and will optionally move it below a new entry.ModifyDNRequest(String dn, String newRDN, boolean deleteOldRDN) Creates a new modify DN request that will rename the entry but will not move it below a new entry.ModifyDNRequest(String dn, String newRDN, boolean deleteOldRDN, Control[] controls) Creates a new modify DN request that will rename the entry but will not move it below a new entry.ModifyDNRequest(String dn, String newRDN, boolean deleteOldRDN, String newSuperiorDN) Creates a new modify DN request that will rename the entry and will optionally move it below a new entry.ModifyDNRequest(String dn, String newRDN, boolean deleteOldRDN, String newSuperiorDN, Control[] controls) Creates a new modify DN request that will rename the entry and will optionally move it below a new entry. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether the current RDN value should be removed from the entry.Creates a new instance of this LDAP request that may be modified without impacting this request.Creates a new instance of this LDAP request that may be modified without impacting this request.Encodes the modify DN request protocol op to an ASN.1 element.getDN()Retrieves the current DN of the entry to move/rename.intRetrieves the message ID for the last LDAP message sent using this request.Retrieves the new RDN for the entry.Retrieves the new superior DN for the entry.Retrieves the type of operation that is represented by this request.byteRetrieves the BER type for this protocol op.protected LDAPResultprocess(LDAPConnection connection, int depth) Sends this modify DN request to the directory server over the provided connection and returns the associated response.voidresponseReceived(LDAPResponse response) voidsetDeleteOldRDN(boolean deleteOldRDN) Specifies whether the current RDN value should be removed from the entry.voidSpecifies the current DN of the entry to move/rename.voidSpecifies the current DN of the entry to move/rename.voidSpecifies the new RDN for the entry.voidSpecifies the new RDN for the entry.voidsetNewSuperiorDN(DN newSuperiorDN) Specifies the new superior DN for the entry.voidsetNewSuperiorDN(String newSuperiorDN) Specifies the new superior DN for the entry.voidAppends a number of lines comprising the Java source code that can be used to recreate this request to the given list.String[]toLDIF()Retrieves a string array whose lines contain an LDIF representation of the corresponding modify DN change record.Retrieves an LDIF modify DN change record with the contents of this modify DN request.Retrieves an LDIF string representation of this modify DN request.voidtoString(StringBuilder buffer) Appends a string representation of this request to the provided buffer.voidwriteTo(ASN1Buffer writer) Writes an ASN.1-encoded representation of this LDAP protocol op to the provided ASN.1 buffer.Methods inherited from class com.unboundid.ldap.sdk.UpdatableLDAPRequest
addControl, addControls, clearControls, removeControl, removeControl, replaceControl, replaceControl, setControls, setControlsMethods inherited from class com.unboundid.ldap.sdk.LDAPRequest
followReferrals, getControl, getControlList, getControls, getIntermediateResponseListener, getReferralConnector, getReferralConnectorInternal, getReferralDepth, getResponseTimeoutMillis, hasControl, hasControl, setFollowReferrals, setIntermediateResponseListener, setReferralConnector, setReferralDepth, setResponseTimeoutMillis, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.unboundid.ldap.sdk.ReadOnlyLDAPRequest
followReferrals, getControl, getControlList, getControls, getReferralConnector, getResponseTimeoutMillis, hasControl, hasControl, toString
-
Constructor Details
-
ModifyDNRequest
Creates a new modify DN request that will rename the entry but will not move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.
-
ModifyDNRequest
Creates a new modify DN request that will rename the entry but will not move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.
-
ModifyDNRequest
public ModifyDNRequest(@NotNull String dn, @NotNull String newRDN, boolean deleteOldRDN, @Nullable String newSuperiorDN) Creates a new modify DN request that will rename the entry and will optionally move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.newSuperiorDN- The new superior DN for the entry. It may benullif the entry is not to be moved below a new parent.
-
ModifyDNRequest
public ModifyDNRequest(@NotNull DN dn, @NotNull RDN newRDN, boolean deleteOldRDN, @Nullable DN newSuperiorDN) Creates a new modify DN request that will rename the entry and will optionally move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.newSuperiorDN- The new superior DN for the entry. It may benullif the entry is not to be moved below a new parent.
-
ModifyDNRequest
public ModifyDNRequest(@NotNull String dn, @NotNull String newRDN, boolean deleteOldRDN, @Nullable Control[] controls) Creates a new modify DN request that will rename the entry but will not move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.controls- The set of controls to include in the request.
-
ModifyDNRequest
public ModifyDNRequest(@NotNull DN dn, @NotNull RDN newRDN, boolean deleteOldRDN, @Nullable Control[] controls) Creates a new modify DN request that will rename the entry but will not move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.controls- The set of controls to include in the request.
-
ModifyDNRequest
public ModifyDNRequest(@NotNull String dn, @NotNull String newRDN, boolean deleteOldRDN, @Nullable String newSuperiorDN, @Nullable Control[] controls) Creates a new modify DN request that will rename the entry and will optionally move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.newSuperiorDN- The new superior DN for the entry. It may benullif the entry is not to be moved below a new parent.controls- The set of controls to include in the request.
-
ModifyDNRequest
public ModifyDNRequest(@NotNull DN dn, @NotNull RDN newRDN, boolean deleteOldRDN, @Nullable DN newSuperiorDN, @Nullable Control[] controls) Creates a new modify DN request that will rename the entry and will optionally move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.newSuperiorDN- The new superior DN for the entry. It may benullif the entry is not to be moved below a new parent.controls- The set of controls to include in the request.
-
-
Method Details
-
getDN
Retrieves the current DN of the entry to move/rename.- Specified by:
getDNin interfaceReadOnlyModifyDNRequest- Returns:
- The current DN of the entry to move/rename.
-
setDN
Specifies the current DN of the entry to move/rename.- Parameters:
dn- The current DN of the entry to move/rename. It must not benull.
-
setDN
Specifies the current DN of the entry to move/rename.- Parameters:
dn- The current DN of the entry to move/rename. It must not benull.
-
getNewRDN
Retrieves the new RDN for the entry.- Specified by:
getNewRDNin interfaceReadOnlyModifyDNRequest- Returns:
- The new RDN for the entry.
-
setNewRDN
Specifies the new RDN for the entry.- Parameters:
newRDN- The new RDN for the entry. It must not benull.
-
setNewRDN
Specifies the new RDN for the entry.- Parameters:
newRDN- The new RDN for the entry. It must not benull.
-
deleteOldRDN
Indicates whether the current RDN value should be removed from the entry.- Specified by:
deleteOldRDNin interfaceReadOnlyModifyDNRequest- Returns:
trueif the current RDN value should be removed from the entry, orfalseif not.
-
setDeleteOldRDN
Specifies whether the current RDN value should be removed from the entry.- Parameters:
deleteOldRDN- Specifies whether the current RDN value should be removed from the entry.
-
getNewSuperiorDN
Retrieves the new superior DN for the entry.- Specified by:
getNewSuperiorDNin interfaceReadOnlyModifyDNRequest- Returns:
- The new superior DN for the entry, or
nullif the entry is not to be moved below a new parent.
-
setNewSuperiorDN
Specifies the new superior DN for the entry.- Parameters:
newSuperiorDN- The new superior DN for the entry. It may benullif the entry is not to be removed below a new parent.
-
setNewSuperiorDN
Specifies the new superior DN for the entry.- Parameters:
newSuperiorDN- The new superior DN for the entry. It may benullif the entry is not to be removed below a new parent.
-
getProtocolOpType
Retrieves the BER type for this protocol op.- Specified by:
getProtocolOpTypein interfaceProtocolOp- Returns:
- The BER type for this protocol op.
-
writeTo
Writes an ASN.1-encoded representation of this LDAP protocol op to the provided ASN.1 buffer. This method is intended for internal use only and should not be used by third-party code.- Specified by:
writeToin interfaceProtocolOp- Parameters:
writer- The ASN.1 buffer to which the encoded representation should be written.
-
encodeProtocolOp
Encodes the modify DN request protocol op to an ASN.1 element.- Specified by:
encodeProtocolOpin interfaceProtocolOp- Returns:
- The ASN.1 element with the encoded modify DN request protocol op.
-
process
@NotNull protected LDAPResult process(@NotNull LDAPConnection connection, int depth) throws LDAPException Sends this modify DN request to the directory server over the provided connection and returns the associated response.- Specified by:
processin classLDAPRequest- Parameters:
connection- The connection to use to communicate with the directory server.depth- The current referral depth for this request. It should always be one for the initial request, and should only be incremented when following referrals.- Returns:
- An LDAP result object that provides information about the result of the modify DN processing.
- Throws:
LDAPException- If a problem occurs while sending the request or reading the response.
-
responseReceived
- Throws:
LDAPException
-
getLastMessageID
Retrieves the message ID for the last LDAP message sent using this request.- Specified by:
getLastMessageIDin classLDAPRequest- Returns:
- The message ID for the last LDAP message sent using this request, or -1 if it no LDAP messages have yet been sent using this request.
-
getOperationType
Retrieves the type of operation that is represented by this request.- Specified by:
getOperationTypein classLDAPRequest- Returns:
- The type of operation that is represented by this request.
-
duplicate
Creates a new instance of this LDAP request that may be modified without impacting this request.- Specified by:
duplicatein interfaceReadOnlyLDAPRequest- Specified by:
duplicatein interfaceReadOnlyModifyDNRequest- Returns:
- A new instance of this LDAP request that may be modified without impacting this request.
-
duplicate
Creates a new instance of this LDAP request that may be modified without impacting this request. The provided controls will be used for the new request instead of duplicating the controls from this request.- Specified by:
duplicatein interfaceReadOnlyLDAPRequest- Specified by:
duplicatein interfaceReadOnlyModifyDNRequest- Parameters:
controls- The set of controls to include in the duplicate request.- Returns:
- A new instance of this LDAP request that may be modified without impacting this request.
-
toLDIFChangeRecord
Retrieves an LDIF modify DN change record with the contents of this modify DN request.- Specified by:
toLDIFChangeRecordin interfaceReadOnlyModifyDNRequest- Returns:
- An LDIF modify DN change record with the contents of this modify DN request.
-
toLDIF
Retrieves a string array whose lines contain an LDIF representation of the corresponding modify DN change record.- Specified by:
toLDIFin interfaceReadOnlyModifyDNRequest- Returns:
- A string array whose lines contain an LDIF representation of the corresponding modify DN change record.
-
toLDIFString
Retrieves an LDIF string representation of this modify DN request.- Specified by:
toLDIFStringin interfaceReadOnlyModifyDNRequest- Returns:
- An LDIF string representation of this modify DN request.
-
toString
Appends a string representation of this request to the provided buffer.- Specified by:
toStringin interfaceProtocolOp- Specified by:
toStringin interfaceReadOnlyLDAPRequest- Specified by:
toStringin classLDAPRequest- Parameters:
buffer- The buffer to which to append a string representation of this request.
-
toCode
public void toCode(@NotNull List<String> lineList, @NotNull String requestID, int indentSpaces, boolean includeProcessing) Appends a number of lines comprising the Java source code that can be used to recreate this request to the given list.- Specified by:
toCodein interfaceReadOnlyLDAPRequest- Parameters:
lineList- The list to which the source code lines should be added.requestID- The name that should be used as an identifier for the request. If this isnullor empty, then a generic ID will be used.indentSpaces- The number of spaces that should be used to indent the generated code. It must not be negative.includeProcessing- Indicates whether the generated code should include code required to actually process the request and handle the result (iftrue), or just to generate the request (iffalse).
-