|
LDAP Classes Implements Java LDAP |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.novell.ldap.LDAPConnection
The central class that encapsulates the connection to a directory server through the LDAP protocol. LDAPConnection objects are used to perform common LDAP operations such as search, modify and add.
In addition, LDAPConnection objects allow you to bind to an LDAP server, set connection and search constraints, and perform several other tasks.
An LDAPConnection object is not connected on construction and can only be connected to one server at one port. Multiple threads may share this single connection, typically by cloning the connection object, one for each thread. An application may have more than one LDAPConnection object, connected to the same or different directory servers.
Sample Code: Search.java
Field Summary | |
static java.lang.String |
ALL_USER_ATTRS
Used with search instead of an attribute list to indicate that all attributes are to be returned. |
static int |
DEFAULT_PORT
The default port number for LDAP servers. |
static int |
DEFAULT_SSL_PORT
The default SSL port number for LDAP servers. |
static java.lang.String |
LDAP_PROPERTY_PROTOCOL
A string that can be passed in to the getProperty method. |
static java.lang.String |
LDAP_PROPERTY_SDK
A string that can be passed in to the getProperty method. |
static java.lang.String |
LDAP_PROPERTY_SECURITY
A string that can be passed in to the getProperty method. |
static int |
LDAP_V3
Specifies the LDAPv3 protocol version when performing a bind operation. |
static java.lang.String |
NO_ATTRS
Used with search instead of an attribute list to indicate that no attributes are to be returned. |
static int |
SCOPE_BASE
Used with search to specify that the scope of entrys to search is to search only the base obect. |
static int |
SCOPE_ONE
Used with search to specify that the scope of entrys to search is to search only the immediate subordinates of the base obect. |
static int |
SCOPE_SUB
Used with search to specify that the scope of entrys to search is to search the base object and all entries within its subtree. |
static int |
SCOPE_SUBORDINATESUBTREE
Used with search to specify that the scope of entries to search is to search the subordinate subtree object and all entries within it. |
static java.lang.String |
SERVER_SHUTDOWN_OID
A string that corresponds to the server shutdown notification OID. |
Constructor Summary | |
LDAPConnection()
Constructs a new LDAPConnection object, which represents a connection to an LDAP server. |
|
LDAPConnection(int timeout)
Constructs a new LDAPConnection object, which will use the supplied timeout value(in MILLISECONDS) to construct a socket connection during LDAPConnection.connect method with the specified socket connect timeout value. |
|
LDAPConnection(LDAPSocketFactory factory)
Constructs a new LDAPConnection object, which will use the supplied class factory to construct a socket connection during LDAPConnection.connect method. |
Method Summary | |
void |
abandon(int id)
Abandons an asynchronous operation. |
void |
abandon(int id,
LDAPConstraints cons)
Abandons an asynchronous operation, using the specified constraints. |
void |
abandon(LDAPMessageQueue queue)
Abandons all outstanding operations managed by the queue. |
void |
abandon(LDAPMessageQueue queue,
LDAPConstraints cons)
Abandons all outstanding operations managed by the queue. |
void |
abandon(LDAPSearchResults results)
Notifies the server not to send additional results associated with this LDAPSearchResults object, and discards any results already received. |
void |
abandon(LDAPSearchResults results,
LDAPConstraints cons)
Notifies the server not to send additional results associated with this LDAPSearchResults object, and discards any results already received. |
void |
add(LDAPEntry entry)
Synchronously adds an entry to the directory. |
void |
add(LDAPEntry entry,
LDAPConstraints cons)
Synchronously adds an entry to the directory, using the specified constraints. |
LDAPResponseQueue |
add(LDAPEntry entry,
LDAPResponseQueue queue)
Asynchronously adds an entry to the directory. |
LDAPResponseQueue |
add(LDAPEntry entry,
LDAPResponseQueue queue,
LDAPConstraints cons)
Asynchronously adds an entry to the directory, using the specified constraints. |
void |
addUnsolicitedNotificationListener(LDAPUnsolicitedNotificationListener listener)
Registers an object to be notified on arrival of an unsolicited message from a server. |
void |
bind(int version,
java.lang.String dn,
byte[] passwd)
Synchronously authenticates to the LDAP server (that the object is currently connected to) using the specified name, password, and LDAP version. |
void |
bind(int version,
java.lang.String dn,
byte[] passwd,
LDAPConstraints cons)
Synchronously authenticates to the LDAP server (that the object is currently connected to) using the specified name, password, LDAP version, and constraints. |
LDAPResponseQueue |
bind(int version,
java.lang.String dn,
byte[] passwd,
LDAPResponseQueue queue)
Asynchronously authenticates to the LDAP server (that the object is currently connected to) using the specified name, password, LDAP version, and queue. |
LDAPResponseQueue |
bind(int version,
java.lang.String dn,
byte[] passwd,
LDAPResponseQueue queue,
LDAPConstraints cons)
Asynchronously authenticates to the LDAP server (that the object is currently connected to) using the specified name, password, LDAP version, queue, and constraints. |
void |
bind(int version,
java.lang.String dn,
java.lang.String passwd)
Deprecated. replaced by bind(int, String, byte[]) |
void |
bind(int version,
java.lang.String dn,
java.lang.String passwd,
LDAPConstraints cons)
Deprecated. replaced by bind(int, String, byte[], LDAPConstraints) |
void |
bind(java.lang.String dn,
java.lang.String passwd)
Deprecated. replaced by bind(int, String, byte[]) |
void |
bind(java.lang.String dn,
java.lang.String passwd,
LDAPConstraints cons)
Deprecated. replaced by bind(int, String, byte[], LDAPConstraints) |
void |
bind(java.lang.String dn,
java.lang.String authzId,
java.util.Map props,
java.lang.Object cbh)
Synchronously authenticates to the LDAP server (that the object is currently connected to) using the specified name and the specified set of mechanisms. |
void |
bind(java.lang.String dn,
java.lang.String authzId,
java.util.Map props,
java.lang.Object cbh,
LDAPConstraints cons)
Synchronously authenticates to the LDAP server (that the object is currently connected to) using the specified name and the specified set of mechanisms. |
void |
bind(java.lang.String dn,
java.lang.String authzId,
java.lang.String[] mechanisms,
java.util.Map props,
java.lang.Object cbh)
Synchronously authenticates to the LDAP server (that the object is currently connected to) using the specified name and the specified set of mechanisms. |
void |
bind(java.lang.String dn,
java.lang.String authzId,
java.lang.String[] mechanisms,
java.util.Map props,
java.lang.Object cbh,
LDAPConstraints cons)
Synchronously authenticates to the LDAP server (that the object is currently connected to) using the specified name and the specified set of mechanisms. |
java.lang.Object |
clone()
Returns a copy of the object with a private context, but sharing the network connection if there is one. |
boolean |
compare(java.lang.String dn,
LDAPAttribute attr)
Synchronously checks to see if an entry contains an attribute with a specified value. |
boolean |
compare(java.lang.String dn,
LDAPAttribute attr,
LDAPConstraints cons)
Synchronously checks to see if an entry contains an attribute with a specified value, using the specified constraints. |
LDAPResponseQueue |
compare(java.lang.String dn,
LDAPAttribute attr,
LDAPResponseQueue queue)
Asynchronously compares an attribute value with one in the directory, using the specified queue. |
LDAPResponseQueue |
compare(java.lang.String dn,
LDAPAttribute attr,
LDAPResponseQueue queue,
LDAPConstraints cons)
Asynchronously compares an attribute value with one in the directory, using the specified queue and contraints. |
void |
connect(java.lang.String host,
int port)
Connects to the specified host and port. |
void |
delete(java.lang.String dn)
Synchronously deletes the entry with the specified distinguished name from the directory. |
void |
delete(java.lang.String dn,
LDAPConstraints cons)
Synchronously deletes the entry with the specified distinguished name from the directory, using the specified constraints. |
LDAPResponseQueue |
delete(java.lang.String dn,
LDAPResponseQueue queue)
Asynchronously deletes the entry with the specified distinguished name from the directory and returns the results to the specified queue. |
LDAPResponseQueue |
delete(java.lang.String dn,
LDAPResponseQueue queue,
LDAPConstraints cons)
Asynchronously deletes the entry with the specified distinguished name from the directory, using the specified contraints and queue. |
void |
disconnect()
Synchronously disconnects from the LDAP server. |
void |
disconnect(LDAPConstraints cons)
Synchronously disconnects from the LDAP server. |
LDAPExtendedResponse |
extendedOperation(LDAPExtendedOperation op)
Provides a synchronous means to access extended, non-mandatory operations offered by a particular LDAPv3 compliant server. |
LDAPExtendedResponse |
extendedOperation(LDAPExtendedOperation op,
LDAPConstraints cons)
Provides a synchronous means to access extended, non-mandatory operations offered by a particular LDAPv3 compliant server. |
LDAPResponseQueue |
extendedOperation(LDAPExtendedOperation op,
LDAPConstraints cons,
LDAPResponseQueue queue)
Provides an asynchronous means to access extended, non-mandatory operations offered by a particular LDAPv3 compliant server. |
LDAPResponseQueue |
extendedOperation(LDAPExtendedOperation op,
LDAPResponseQueue queue)
Provides an asynchronous means to access extended, non-mandatory operations offered by a particular LDAPv3 compliant server. |
LDAPSchema |
fetchSchema(java.lang.String schemaDN)
Retrieves the schema associated with a particular schema DN in the directory server. |
protected void |
finalize()
Closes the connection, if open, and releases any other resources held by the object. |
java.lang.String |
getAuthenticationDN()
Returns the distinguished name (DN) used for as the bind name during the last successful bind operation. |
java.lang.String |
getAuthenticationMethod()
Returns the method used to authenticate the connection. |
LDAPConstraints |
getConstraints()
Returns a copy of the set of constraints associated with this connection. |
java.lang.String |
getHost()
Returns the host name of the LDAP server to which the object is or was last connected, in the format originally specified. |
int |
getPort()
Returns the port number of the LDAP server to which the object is or was last connected. |
java.lang.Object |
getProperty(java.lang.String name)
Returns a property of a connection object. |
int |
getProtocolVersion()
Returns the protocol version uses to authenticate. |
LDAPControl[] |
getResponseControls()
Returns the Server Controls associated with the most recent response to a synchronous request on this connection object, or null if the latest response contained no Server Controls. |
java.lang.Object |
getSaslBindCallbackHandler()
Returns the call back handler if any specified on binding with a SASL mechanism. |
java.util.Map |
getSaslBindProperties()
Returns the properties if any specified on binding with a SASL mechanism. |
java.lang.String |
getSchemaDN()
Retrieves the Distiguished Name (DN) for the schema advertised in the root DSE of the Directory Server. |
java.lang.String |
getSchemaDN(java.lang.String dn)
Retrieves the Distiguished Name (DN) of the schema associated with a entry in the Directory. |
LDAPSearchConstraints |
getSearchConstraints()
Returns a copy of the set of search constraints associated with this connection. |
LDAPSocketFactory |
getSocketFactory()
Returns the LDAPSocketFactory used to establish this server connection. |
int |
getSocketTimeOut()
Returns the SocketTimeOut value set in milliseconds. |
boolean |
isBound()
Indicates whether the object has authenticated to the connected LDAP server. |
boolean |
isConnected()
Indicates whether the connection represented by this object is open at this time. |
boolean |
isConnectionAlive()
Checks whether the connection represented by this object is still alive or not. |
boolean |
isTLS()
Indicatates if the connection is protected by TLS. |
protected LDAPMessage |
makeExtendedOperation(LDAPExtendedOperation op,
LDAPConstraints cons)
Formulates the extended operation, constraints into an LDAPMessage and returns the LDAPMessage. |
void |
modify(java.lang.String dn,
LDAPModification mod)
Synchronously makes a single change to an existing entry in the directory. |
void |
modify(java.lang.String dn,
LDAPModification[] mods)
Synchronously makes a set of changes to an existing entry in the directory. |
void |
modify(java.lang.String dn,
LDAPModification[] mods,
LDAPConstraints cons)
Synchronously makes a set of changes to an existing entry in the directory, using the specified constraints. |
LDAPResponseQueue |
modify(java.lang.String dn,
LDAPModification[] mods,
LDAPResponseQueue queue)
Asynchronously makes a set of changes to an existing entry in the directory. |
LDAPResponseQueue |
modify(java.lang.String dn,
LDAPModification[] mods,
LDAPResponseQueue queue,
LDAPConstraints cons)
Asynchronously makes a set of changes to an existing entry in the directory, using the specified constraints and queue. |
void |
modify(java.lang.String dn,
LDAPModification mod,
LDAPConstraints cons)
Synchronously makes a single change to an existing entry in the directory, using the specified constraints. |
LDAPResponseQueue |
modify(java.lang.String dn,
LDAPModification mod,
LDAPResponseQueue queue)
Asynchronously makes a single change to an existing entry in the directory. |
LDAPResponseQueue |
modify(java.lang.String dn,
LDAPModification mod,
LDAPResponseQueue queue,
LDAPConstraints cons)
Asynchronously makes a single change to an existing entry in the directory, using the specified constraints and queue. |
static LDAPEntry |
read(LDAPUrl toGet)
Synchronously reads the entry specified by the LDAP URL. |
static LDAPEntry |
read(LDAPUrl toGet,
LDAPSearchConstraints cons)
Synchronously reads the entry specified by the LDAP URL, using the specified constraints. |
LDAPEntry |
read(java.lang.String dn)
Synchronously reads the entry for the specified distiguished name (DN) and retrieves all attributes for the entry. |
LDAPEntry |
read(java.lang.String dn,
LDAPSearchConstraints cons)
Synchronously reads the entry for the specified distiguished name (DN), using the specified constraints, and retrieves all attributes for the entry. |
LDAPEntry |
read(java.lang.String dn,
java.lang.String[] attrs)
Synchronously reads the entry for the specified distinguished name (DN) and retrieves only the specified attributes from the entry. |
LDAPEntry |
read(java.lang.String dn,
java.lang.String[] attrs,
LDAPSearchConstraints cons)
Synchronously reads the entry for the specified distinguished name (DN), using the specified constraints, and retrieves only the specified attributes from the entry. |
void |
removeUnsolicitedNotificationListener(LDAPUnsolicitedNotificationListener listener)
Deregisters an object so that it will no longer be notified on arrival of an unsolicited message from a server. |
void |
rename(java.lang.String dn,
java.lang.String newRdn,
boolean deleteOldRdn)
Synchronously renames an existing entry in the directory. |
void |
rename(java.lang.String dn,
java.lang.String newRdn,
boolean deleteOldRdn,
LDAPConstraints cons)
Synchronously renames an existing entry in the directory, using the specified constraints. |
LDAPResponseQueue |
rename(java.lang.String dn,
java.lang.String newRdn,
boolean deleteOldRdn,
LDAPResponseQueue queue)
Asynchronously renames an existing entry in the directory. |
LDAPResponseQueue |
rename(java.lang.String dn,
java.lang.String newRdn,
boolean deleteOldRdn,
LDAPResponseQueue queue,
LDAPConstraints cons)
Asynchronously renames an existing entry in the directory, using the specified constraints. |
void |
rename(java.lang.String dn,
java.lang.String newRdn,
java.lang.String newParentdn,
boolean deleteOldRdn)
Synchronously renames an existing entry in the directory, possibly repositioning the entry in the directory tree. |
void |
rename(java.lang.String dn,
java.lang.String newRdn,
java.lang.String newParentdn,
boolean deleteOldRdn,
LDAPConstraints cons)
Synchronously renames an existing entry in the directory, using the specified constraints and possibly repositioning the entry in the directory tree. |
LDAPResponseQueue |
rename(java.lang.String dn,
java.lang.String newRdn,
java.lang.String newParentdn,
boolean deleteOldRdn,
LDAPResponseQueue queue)
Asynchronously renames an existing entry in the directory, possibly repositioning the entry in the directory. |
LDAPResponseQueue |
rename(java.lang.String dn,
java.lang.String newRdn,
java.lang.String newParentdn,
boolean deleteOldRdn,
LDAPResponseQueue queue,
LDAPConstraints cons)
Asynchronously renames an existing entry in the directory, using the specified constraints and possibily repositioning the entry in the directory. |
static LDAPSearchResults |
search(LDAPUrl toGet)
Synchronously performs the search specified by the LDAP URL, returning an enumerable LDAPSearchResults object. |
static LDAPSearchResults |
search(LDAPUrl toGet,
LDAPSearchConstraints cons)
Synchronously perfoms the search specified by the LDAP URL, using the specified search constraints (such as the maximum number of entries to find or the maximum time to wait for search results). |
LDAPSearchResults |
search(java.lang.String base,
int scope,
java.lang.String filter,
java.lang.String[] attrs,
boolean typesOnly)
Synchronously performs the search specified by the parameters. |
LDAPSearchResults |
search(java.lang.String base,
int scope,
java.lang.String filter,
java.lang.String[] attrs,
boolean typesOnly,
LDAPSearchConstraints cons)
Synchronously performs the search specified by the parameters, using the specified search constraints (such as the maximum number of entries to find or the maximum time to wait for search results). |
LDAPSearchQueue |
search(java.lang.String base,
int scope,
java.lang.String filter,
java.lang.String[] attrs,
boolean typesOnly,
LDAPSearchQueue queue)
Asynchronously performs the search specified by the parameters. |
LDAPSearchQueue |
search(java.lang.String base,
int scope,
java.lang.String filter,
java.lang.String[] attrs,
boolean typesOnly,
LDAPSearchQueue queue,
LDAPSearchConstraints cons)
Asynchronously performs the search specified by the parameters, also allowing specification of constraints for the search (such as the maximum number of entries to find or the maximum time to wait for search results). |
LDAPMessageQueue |
sendRequest(LDAPMessage request,
LDAPMessageQueue queue)
Sends an LDAP request to a directory server. |
LDAPMessageQueue |
sendRequest(LDAPMessage request,
LDAPMessageQueue queue,
LDAPConstraints cons)
Sends an LDAP request to a directory server. |
void |
setConstraints(LDAPConstraints cons)
Sets the constraints that apply to all operations performed through this connection (unless a different set of constraints is specified when calling an operation method). |
static void |
setSocketFactory(LDAPSocketFactory factory)
Establishes the default LDAPSocketFactory used when LDAPConnection objects are constructed unless an LDAPSocketFactory is specified in the LDAPConnection object constructor. |
void |
setSocketTimeOut(int timeout)
Sets the SocketTimeOut value in milliseconds. |
void |
startTLS()
Starts Transport Layer Security (TLS) protocol on this connection to enable session privacy. |
void |
stopTLS()
Stops Transport Layer Security(TLS) on the LDAPConnection and reverts back to an anonymous state. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int SCOPE_BASE
SCOPE_BASE = 0
public static final int SCOPE_ONE
SCOPE_ONE = 1
public static final int SCOPE_SUB
SCOPE_ONE = 2
public static final int SCOPE_SUBORDINATESUBTREE
SCOPE_SUBORDINATESUBTREE = 4
public static final java.lang.String NO_ATTRS
NO_ATTRS = "1.1"
public static final java.lang.String ALL_USER_ATTRS
ALL_USER_ATTRS = "*"
public static final int LDAP_V3
Specifies LDAP version V3 of the protocol, and is specified when performing bind operations.
You can use this identifier in the version parameter of the bind method to specify an LDAPv3 bind. LDAP_V3 is the default protocol version
LDAP_V3 = 3
bind(int, String, byte[])
,
bind(int, String, byte[], LDAPConstraints)
,
bind(int, String, byte[], LDAPResponseQueue)
,
bind(int, String, byte[], LDAPResponseQueue, LDAPConstraints)
,
Constant Field Valuespublic static final int DEFAULT_PORT
You can use this identifier to specify the port when establishing a clear text connection to a server. This the default port.
DEFAULT_PORT = 389
connect(String, int)
,
Constant Field Valuespublic static final int DEFAULT_SSL_PORT
DEFAULT_SSL_PORT = 636
You can use this identifier to specify the port when establishing a an SSL connection to a server.
.
public static final java.lang.String LDAP_PROPERTY_SDK
LDAP_PROPERTY_SDK = "version.sdk"
You can use this string to request the version of the SDK
.
public static final java.lang.String LDAP_PROPERTY_PROTOCOL
LDAP_PROPERTY_PROTOCOL = "version.protocol"
You can use this string to request the version of the LDAP protocol
.
public static final java.lang.String LDAP_PROPERTY_SECURITY
LDAP_PROPERTY_SECURITY = "version.security"
You can use this string to request the type of security being used
.
public static final java.lang.String SERVER_SHUTDOWN_OID
SERVER_SHUTDOWN_OID = "1.3.6.1.4.1.1466.20036"
Constructor Detail |
public LDAPConnection()
Calling the constructor does not actually establish the connection. To connect to the LDAP server, use the connect method.
connect(String, int)
public LDAPConnection(LDAPSocketFactory factory)
factory
- An object capable of producing a Socket.connect(String, int)
,
getSocketFactory()
,
setSocketFactory( LDAPSocketFactory)
public LDAPConnection(int timeout)
timeout
- An object capable of producing a Socket
with the specified Socket Connect timeout value.getSocketTimeOut()
,
setSocketTimeOut(int)
Method Detail |
public java.lang.Object clone()
The network connection remains open until all clones have disconnected or gone out of scope. Any connection opened after cloning is private to the object making the connection.
The clone can issue requests and freely modify options and search constraints, and , without affecting the source object or other clones. If the clone disconnects or reconnects, it is completely dissociated from the source object and other clones. Reauthenticating in a clone, however, is a global operation which will affect the source object and all associated clones, because it applies to the single shared physical connection. Any request by an associated object after one has reauthenticated will carry the new identity.
protected void finalize() throws LDAPException
LDAPException
- A general exception which includes an error
message and an LDAP error code.disconnect()
public int getProtocolVersion()
0 is returned if no authentication has been performed.
bind( int, String, String)
public java.lang.String getAuthenticationDN()
null
is returned
if no authentication has been performed or if the bind resulted in
an aonymous connection.
bind( String, String)
,
isBound()
public java.lang.String getAuthenticationMethod()
public java.util.Map getSaslBindProperties()
Null is returned if no authentication has been performed or no authentication Map is present.
bind( String, String, String[], Map, Object )
public java.lang.Object getSaslBindCallbackHandler()
Null is returned if no authentication has been performed or no authentication call back handler is present.
bind( String, String, String[], Map, Object )
public LDAPConstraints getConstraints()
setConstraints(LDAPConstraints)
public java.lang.String getHost()
connect( String, int)
public int getPort()
connect( String, int)
public java.lang.Object getProperty(java.lang.String name)
name
- Name of the property to be returned.
The following read-only properties are available for any given connection:
A deep copy of the property is provided where applicable; a client does not need to clone the object received.
LDAPConstraints.getProperty(String)
,
LDAPConstraints.setProperty(String, Object)
public LDAPSearchConstraints getSearchConstraints()
setConstraints(com.novell.ldap.LDAPConstraints)
,
search( String, int, String, String[], boolean, LDAPSearchConstraints)
public LDAPSocketFactory getSocketFactory()
LDAPConnection( LDAPSocketFactory)
,
setSocketFactory( LDAPSocketFactory)
public boolean isBound()
bind( String, String)
public boolean isConnected()
public boolean isConnectionAlive()
public boolean isTLS()
startTLS()
,
stopTLS()
public int getSocketTimeOut()
setSocketTimeOut(int)
public void setSocketTimeOut(int timeout)
getSocketTimeOut()
public void setConstraints(LDAPConstraints cons)
cons
- An LDAPConstraints or LDAPSearchConstraints Object
containing the contstraint values to set.getConstraints()
,
getSearchConstraints()
public static void setSocketFactory(LDAPSocketFactory factory)
This method sets the default LDAPSocketFactory used for all subsequent LDAPConnection objects constructed. If called after LDAPConnection objects are created, those already created are not affected even if they disconnect and establish a new connection. It affects LDAPConnection objects only as they are constructed.
The following code snippet provides a typical usage example:
if (usingTLS) {
LDAPConnection.setSocketFactory(myTLSFactory);
}
...
LDAPConnection conn = new LDAPConnection();
conn.connect(myHost, myPort);
In this example, connections are constructed with the default LDAPSocketFactory. At application start-up time, the default may be set to use a particular provided TLS socket factory.
factory
- A factory object which can construct socket
connections for an LDAPConnection.LDAPConnection( LDAPSocketFactory)
public void addUnsolicitedNotificationListener(LDAPUnsolicitedNotificationListener listener)
An unsolicited message has the ID 0. A new thread is created and the method "messageReceived" in each registered object is called in turn.
listener
- An object to be notified on arrival of an
unsolicited message from a server. This object must
implement the LDAPUnsolicitedNotificationListener interface.public void removeUnsolicitedNotificationListener(LDAPUnsolicitedNotificationListener listener)
listener
- An object to no longer be notified on arrival of
an unsolicited message from a server.public void startTLS() throws LDAPException
This affects the LDAPConnection object and all cloned objects. A socket factory that implements LDAPTLSSocketFactory must be set on the connection.
LDAPException
- Thrown if TLS cannot be started. If a
SocketFactory has been specified that does not implement
LDAPTLSSocketFactory an LDAPException is thrown.isTLS()
,
stopTLS()
,
setSocketFactory(com.novell.ldap.LDAPSocketFactory)
public void stopTLS() throws LDAPException
LDAPException
- This can occur for the following reasons: Note: The Sun and IBM implementions of JSSE do not currently allow stopping TLS on an open Socket. In order to produce the same results this method currently disconnects the socket and reconnects, giving the application an anonymous connection to the server, as required by StopTLS.
startTLS()
,
isTLS()
public void abandon(LDAPSearchResults results) throws LDAPException
results
- An object returned from a search.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void abandon(LDAPSearchResults results, LDAPConstraints cons) throws LDAPException
results
- An object returned from a search.
cons
- The contraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void abandon(int id) throws LDAPException
id
- The ID of the asynchronous operation to abandon. The ID
can be obtained from the response queue for the
operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void abandon(int id, LDAPConstraints cons) throws LDAPException
id
- The ID of the asynchronous operation to abandon.
The ID can be obtained from the search
queue for the operation.
cons
- The contraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void abandon(LDAPMessageQueue queue) throws LDAPException
All operations in progress, which are managed by the specified queue, are abandoned.
queue
- The queue returned from an asynchronous request.
All outstanding operations managed by the queue
are abandoned, and the queue is emptied.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void abandon(LDAPMessageQueue queue, LDAPConstraints cons) throws LDAPException
All operations in progress, which are managed by the specified queue, are abandoned.
queue
- The queue returned from an asynchronous request.
All outstanding operations managed by the queue
are abandoned, and the queue is emptied.
cons
- The contraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void add(LDAPEntry entry) throws LDAPException
entry
- LDAPEntry object specifying the distinguished
name and attributes of the new entry.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void add(LDAPEntry entry, LDAPConstraints cons) throws LDAPException
entry
- LDAPEntry object specifying the distinguished
name and attributes of the new entry.
cons
- Constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue add(LDAPEntry entry, LDAPResponseQueue queue) throws LDAPException
entry
- LDAPEntry object specifying the distinguished
name and attributes of the new entry.
queue
- Handler for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue add(LDAPEntry entry, LDAPResponseQueue queue, LDAPConstraints cons) throws LDAPException
entry
- LDAPEntry object specifying the distinguished
name and attributes of the new entry.
queue
- Handler for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
cons
- Constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void bind(java.lang.String dn, java.lang.String passwd) throws LDAPException
bind(int, String, byte[])
If the object has been disconnected from an LDAP server, this method attempts to reconnect to the server. If the object has already authenticated, the old authentication is discarded.
dn
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name.
passwd
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name and passwd as password.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void bind(int version, java.lang.String dn, java.lang.String passwd) throws LDAPException
bind(int, String, byte[])
If the object has been disconnected from an LDAP server, this method attempts to reconnect to the server. If the object has already authenticated, the old authentication is discarded.
version
- The LDAP protocol version, use LDAP_V3.
LDAP_V2 is not supported.
dn
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name.
passwd
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name and passwd as password.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void bind(java.lang.String dn, java.lang.String passwd, LDAPConstraints cons) throws LDAPException
bind(int, String, byte[], LDAPConstraints)
If the object has been disconnected from an LDAP server, this method attempts to reconnect to the server. If the object has already authenticated, the old authentication is discarded.
dn
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name.
passwd
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name and passwd as password.
Note: the application should use care in the use
of String password objects. These are long lived
objects, and may expose a security risk, especially
in objects that are serialized. The LDAPConnection
keeps no long lived instances of these objects.
cons
- Constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void bind(int version, java.lang.String dn, java.lang.String passwd, LDAPConstraints cons) throws LDAPException
bind(int, String, byte[], LDAPConstraints)
If the object has been disconnected from an LDAP server, this method attempts to reconnect to the server. If the object has already authenticated, the old authentication is discarded.
version
- The LDAP protocol version, use LDAP_V3.
LDAP_V2 is not supported.
dn
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name.
passwd
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name and passwd as password.
cons
- The constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void bind(int version, java.lang.String dn, byte[] passwd) throws LDAPException
If the object has been disconnected from an LDAP server, this method attempts to reconnect to the server. If the object has already authenticated, the old authentication is discarded.
version
- The version of the LDAP protocol to use
in the bind, use LDAP_V3. LDAP_V2 is not supported.
dn
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name.
passwd
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name and passwd as password.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void bind(int version, java.lang.String dn, byte[] passwd, LDAPConstraints cons) throws LDAPException
If the object has been disconnected from an LDAP server, this method attempts to reconnect to the server. If the object has already authenticated, the old authentication is discarded.
version
- The LDAP protocol version, use LDAP_V3.
LDAP_V2 is not supported.
dn
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name.
passwd
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name and passwd as password.
cons
- The constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue bind(int version, java.lang.String dn, byte[] passwd, LDAPResponseQueue queue) throws LDAPException
If the object has been disconnected from an LDAP server, this method attempts to reconnect to the server. If the object has already authenticated, the old authentication is discarded.
version
- The LDAP protocol version, use LDAP_V3.
LDAP_V2 is not supported.
dn
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name.
passwd
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name and passwd as password.
queue
- Handler for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue bind(int version, java.lang.String dn, byte[] passwd, LDAPResponseQueue queue, LDAPConstraints cons) throws LDAPException
If the object has been disconnected from an LDAP server, this method attempts to reconnect to the server. If the object had already authenticated, the old authentication is discarded.
version
- The LDAP protocol version, use LDAP_V3.
LDAP_V2 is not supported.
dn
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name.
passwd
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name and passwd as password.
queue
- Handler for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
cons
- Constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void bind(java.lang.String dn, java.lang.String authzId, java.util.Map props, java.lang.Object cbh) throws LDAPException
If none of the requested SASL mechanisms is available, an exception is thrown. If the object has been disconnected from an LDAP server, this method attempts to reconnect to the server. If the object has already authenticated, the old authentication is discarded. If mechanisms is null, or if the first version of the method is called, the LDAP server will be interrogated for its supportedSaslMechanisms attribute of its root DSE. See RFC 2251 for a discussion of the SASL classes.
dn
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name.
authzId
- If not null and not empty, specifies an LDAP authzId to
pass to the SASL layer. If null or empty, the authzId
will be treated as an empty string and processed
as per RFC 2222.
props
- The optional qualifiers for the authentication
session.
cbh
- A class which may be called by the SASL client
implementation to obtain additional information
required, such as additional credentials.
If cbh is not of type
javax.security.auth.callback.CallbackHandler, a
RuntimeException will be thrown.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void bind(java.lang.String dn, java.lang.String authzId, java.util.Map props, java.lang.Object cbh, LDAPConstraints cons) throws LDAPException
If none of the requested SASL mechanisms is available, an exception is thrown. If the object has been disconnected from an LDAP server, this method attempts to reconnect to the server. If the object has already authenticated, the old authentication is discarded. If mechanisms is null, or if the first version of the method is called, the LDAP server will be interrogated for its supportedSaslMechanisms attribute of its root DSE. See RFC 2251 for a discussion of the SASL classes.
dn
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name.
authzId
- If not null and not empty, specifies an LDAP authzId to
pass to the SASL layer. If null or empty, the authzId
will be treated as an empty string and processed
as per RFC 2222.
props
- The optional qualifiers for the authentication
session.
cbh
- A class which may be called by the SASL client
implementation to obtain additional information
required, such as additional credentials.
If cbh is not of type
javax.security.auth.callback.CallbackHandler, a
RuntimeException will be thrown.
cons
- Constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void bind(java.lang.String dn, java.lang.String authzId, java.lang.String[] mechanisms, java.util.Map props, java.lang.Object cbh) throws LDAPException
If none of the requested SASL mechanisms is available, an exception is thrown. If the object has been disconnected from an LDAP server, this method attempts to reconnect to the server. If the object has already authenticated, the old authentication is discarded. If mechanisms is null, or if the first version of the method is called, the LDAP server will be interrogated for its supportedSaslMechanisms attribute of its root DSE. See RFC 2251 for a discussion of the SASL classes.
dn
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name.authzId
- If not null and not empty, specifies an LDAP authzId to
pass to the SASL layer. If null or empty, the authzId
will be treated as an empty string and processed
as per RFC 2222.
mechanisms
- An array of IANA-registered SASL mechanisms which
the client is willing to use for authentication.
props
- The optional qualifiers for the authentication
session.
cbh
- A class which may be called by the SASL client
implementation to obtain additional information
required, such as additional credentials.
If cbh is not of type
javax.security.auth.callback.CallbackHandler, a
RuntimeException will be thrown.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void bind(java.lang.String dn, java.lang.String authzId, java.lang.String[] mechanisms, java.util.Map props, java.lang.Object cbh, LDAPConstraints cons) throws LDAPException
If none of the requested SASL mechanisms is available, an exception is thrown. If the object has been disconnected from an LDAP server, this method attempts to reconnect to the server. If the object has already authenticated, the old authentication is discarded. If mechanisms is null, or if the first version of the method is called, the LDAP server will be interrogated for its supportedSaslMechanisms attribute of its root DSE. See RFC 2251 for a discussion of the SASL classes.
dn
- If non-null and non-empty, specifies that the
connection and all operations through it should
be authenticated with dn as the distinguished
name.authzId
- If not null and not empty, specifies an LDAP authzId to
pass to the SASL layer. If null or empty, the authzId
will be treated as an empty string and processed
as per RFC 2222.
mechanisms
- An array of IANA-registered SASL mechanisms which
the client is willing to use for authentication.
props
- The optional qualifiers for the authentication
session.
cbh
- A class which may be called by the SASL client
implementation to obtain additional information
required, such as additional credentials.
If cbh is not of type
javax.security.auth.callback.CallbackHandler, a
RuntimeException will be thrown.
cons
- Constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public boolean compare(java.lang.String dn, LDAPAttribute attr) throws LDAPException
dn
- The distinguished name of the entry to use in the
comparison.
attr
- The attribute to compare against the entry. The
method checks to see if the entry has an
attribute with the same name and value as this
attribute.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public boolean compare(java.lang.String dn, LDAPAttribute attr, LDAPConstraints cons) throws LDAPException
dn
- The distinguished name of the entry to use in the
comparison.
attr
- The attribute to compare against the entry. The
method checks to see if the entry has an
attribute with the same name and value as this
attribute.
cons
- Constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue compare(java.lang.String dn, LDAPAttribute attr, LDAPResponseQueue queue) throws LDAPException
Please note that a successful completion of this command results in
one of two status codes: LDAPException.COMPARE_TRUE if the entry
has the value, and LDAPException.COMPARE_FALSE if the entry
does not have the value or the attribute.
dn
- The distinguished name of the entry containing an
attribute to compare.
attr
- An attribute to compare.
queue
- The queue for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
LDAPException
- A general exception which includes an error
message and an LDAP error code.LDAPException.COMPARE_TRUE
,
LDAPException.COMPARE_FALSE
public LDAPResponseQueue compare(java.lang.String dn, LDAPAttribute attr, LDAPResponseQueue queue, LDAPConstraints cons) throws LDAPException
Please note that a successful completion of this command results in
one of two status codes: LDAPException.COMPARE_TRUE if the entry
has the value, and LDAPException.COMPARE_FALSE if the entry
does not have the value or the attribute.
dn
- The distinguished name of the entry containing an
attribute to compare.
attr
- An attribute to compare.
queue
- Handler for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
cons
- Constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.LDAPException.COMPARE_TRUE
,
LDAPException.COMPARE_FALSE
public void connect(java.lang.String host, int port) throws LDAPException
If this LDAPConnection object represents an open connection, the connection is closed first before the new connection is opened. At this point, there is no authentication, and any operations are conducted as an anonymous client.
When more than one host name is specified, each host is contacted in turn until a connection can be established.
host
- A host name or a dotted string representing the IP address
of a host running an LDAP server. It may also
contain a list of host names, space-delimited. Each host
name can include a trailing colon and port number.
port
- The TCP or UDP port number to connect to or contact.
The default LDAP port is 389. The port parameter is
ignored for any host hame which includes a colon and
port number.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void delete(java.lang.String dn) throws LDAPException
Note: A Delete operation will not remove an entry that contains subordinate entries, nor will it dereference alias entries.
dn
- The distinguished name of the entry to delete.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void delete(java.lang.String dn, LDAPConstraints cons) throws LDAPException
Note: A Delete operation will not remove an entry that contains subordinate entries, nor will it dereference alias entries.
dn
- The distinguished name of the entry to delete.
cons
- Constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue delete(java.lang.String dn, LDAPResponseQueue queue) throws LDAPException
Note: A Delete operation will not remove an entry that contains subordinate entries, nor will it dereference alias entries.
dn
- The distinguished name of the entry to modify.
queue
- The queue for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue delete(java.lang.String dn, LDAPResponseQueue queue, LDAPConstraints cons) throws LDAPException
Note: A Delete operation will not remove an entry that contains subordinate entries, nor will it dereference alias entries.
dn
- The distinguished name of the entry to delete.
queue
- The queue for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
cons
- The constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void disconnect() throws LDAPException
Before the object can perform LDAP operations again, it must reconnect to the server by calling connect.
The disconnect method abandons any outstanding requests, issues an unbind request to the server, and then closes the socket.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void disconnect(LDAPConstraints cons) throws LDAPException
Before the object can perform LDAP operations again, it must reconnect to the server by calling connect.
The disconnect method abandons any outstanding requests, issues an unbind request to the server, and then closes the socket.
cons
- LDPConstraints to be set with the unbind request
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPExtendedResponse extendedOperation(LDAPExtendedOperation op) throws LDAPException
op
- The object which contains (1) an identifier of an extended
operation which should be recognized by the particular LDAP
server this client is connected to and (2)
an operation-specific sequence of octet strings
or BER-encoded values.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPExtendedResponse extendedOperation(LDAPExtendedOperation op, LDAPConstraints cons) throws LDAPException
op
- The object which contains (1) an identifier of an extended
operation which should be recognized by the particular LDAP
server this client is connected to and (2) an
operation-specific sequence of octet strings
or BER-encoded values.
cons
- The constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue extendedOperation(LDAPExtendedOperation op, LDAPResponseQueue queue) throws LDAPException
op
- The object which contains (1) an identifier of an extended
operation which should be recognized by the particular LDAP
server this client is connected to and (2) an
operation-specific sequence of octet strings
or BER-encoded values.
queue
- The queue for messages returned from a server in
response to this request. If it is null, a queue
object is created internally.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue extendedOperation(LDAPExtendedOperation op, LDAPConstraints cons, LDAPResponseQueue queue) throws LDAPException
op
- The object which contains (1) an identifier of an extended
operation which should be recognized by the particular LDAP
server this client is connected to and (2) an operation-
specific sequence of octet strings or BER-encoded values.
queue
- The queue for messages returned from a server in
response to this request. If it is null, a queue
object is created internally.
cons
- The constraints specific to this operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.protected LDAPMessage makeExtendedOperation(LDAPExtendedOperation op, LDAPConstraints cons) throws LDAPException
LDAPException
public LDAPControl[] getResponseControls()
LDAPMessage.getControls()
public void modify(java.lang.String dn, LDAPModification mod) throws LDAPException
For example, this modify method changes the value of an attribute, adds a new attribute value, or removes an existing attribute value.
The LDAPModification object specifies both the change to be made and the LDAPAttribute value to be changed.
If the request fails with LDAPException.CONNECT_ERROR
,
it is indeterminate whether or not the server made the modification.
dn
- The distinguished name of the entry to modify.
mod
- A single change to be made to the entry.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void modify(java.lang.String dn, LDAPModification mod, LDAPConstraints cons) throws LDAPException
For example, this modify method changes the value of an attribute, adds a new attribute value, or removes an existing attribute value.
The LDAPModification object specifies both the change to be made and the LDAPAttribute value to be changed.
If the request fails with LDAPException.CONNECT_ERROR
,
it is indeterminate whether or not the server made the modification.
dn
- The distinguished name of the entry to modify.
mod
- A single change to be made to the entry.
cons
- The constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void modify(java.lang.String dn, LDAPModification[] mods) throws LDAPException
For example, this modify method changes attribute values, adds new attribute values, or removes existing attribute values.
Because the server applies all changes in an LDAPModification array
atomically, the application can expect that no changes
have been performed if an error is returned.
If the request fails with LDAPException.CONNECT_ERROR
,
it is indeterminate whether or not the server made the modifications.
dn
- Distinguished name of the entry to modify.
mods
- The changes to be made to the entry.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void modify(java.lang.String dn, LDAPModification[] mods, LDAPConstraints cons) throws LDAPException
For example, this modify method changes attribute values, adds new attribute values, or removes existing attribute values.
Because the server applies all changes in an LDAPModification array
atomically, the application can expect that no changes
have been performed if an error is returned.
If the request fails with LDAPException.CONNECT_ERROR
,
it is indeterminate whether or not the server made the modifications.
dn
- The distinguished name of the entry to modify.
mods
- The changes to be made to the entry.
cons
- The constraints specific to the operation.
LDAPException
- A general exception which includes an
error message and an LDAP error code.public LDAPResponseQueue modify(java.lang.String dn, LDAPModification mod, LDAPResponseQueue queue) throws LDAPException
For example, this modify method can change the value of an attribute, add a new attribute value, or remove an existing attribute value.
The LDAPModification object specifies both the change to be made and the LDAPAttribute value to be changed.
If the request fails with LDAPException.CONNECT_ERROR
,
it is indeterminate whether or not the server made the modification.
dn
- Distinguished name of the entry to modify.
mod
- A single change to be made to the entry.
queue
- Handler for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue modify(java.lang.String dn, LDAPModification mod, LDAPResponseQueue queue, LDAPConstraints cons) throws LDAPException
For example, this modify method can change the value of an attribute, add a new attribute value, or remove an existing attribute value.
The LDAPModification object specifies both the change to be made and the LDAPAttribute value to be changed.
If the request fails with LDAPException.CONNECT_ERROR
,
it is indeterminate whether or not the server made the modification.
dn
- Distinguished name of the entry to modify.
mod
- A single change to be made to the entry.
queue
- Handler for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
cons
- Constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue modify(java.lang.String dn, LDAPModification[] mods, LDAPResponseQueue queue) throws LDAPException
For example, this modify method can change attribute values, add new attribute values, or remove existing attribute values.
Because the server applies all changes in an LDAPModification array
atomically, the application can expect that no changes
have been performed if an error is returned.
If the request fails with LDAPException.CONNECT_ERROR
,
it is indeterminate whether or not the server made the modifications.
dn
- The distinguished name of the entry to modify.
mods
- The changes to be made to the entry.
queue
- The queue for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue modify(java.lang.String dn, LDAPModification[] mods, LDAPResponseQueue queue, LDAPConstraints cons) throws LDAPException
For example, this modify method can change attribute values, add new attribute values, or remove existing attribute values.
Because the server applies all changes in an LDAPModification array
atomically, the application can expect that no changes
have been performed if an error is returned.
If the request fails with LDAPException.CONNECT_ERROR
,
it is indeterminate whether or not the server made the modifications.
dn
- The distinguished name of the entry to modify.
mods
- The changes to be made to the entry.
queue
- The queue for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
cons
- Constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPEntry read(java.lang.String dn) throws LDAPException
dn
- The distinguished name of the entry to retrieve.
LDAPException
- if the object was not foundpublic LDAPEntry read(java.lang.String dn, LDAPSearchConstraints cons) throws LDAPException
dn
- The distinguished name of the entry to retrieve.
cons
- The constraints specific to the operation.
LDAPException
- if the object was not foundpublic LDAPEntry read(java.lang.String dn, java.lang.String[] attrs) throws LDAPException
dn
- The distinguished name of the entry to retrieve.
attrs
- The names of the attributes to retrieve.
LDAPException
- if the object was not foundpublic LDAPEntry read(java.lang.String dn, java.lang.String[] attrs, LDAPSearchConstraints cons) throws LDAPException
dn
- The distinguished name of the entry to retrieve.
attrs
- The names of the attributes to retrieve.
cons
- The constraints specific to the operation.
LDAPException
- if the object was not foundpublic static LDAPEntry read(LDAPUrl toGet) throws LDAPException
When this read method is called, a new connection is created automatically, using the host and port specified in the URL. After finding the entry, the method closes the connection (in other words, it disconnects from the LDAP server).
If the URL specifies a filter and scope, they are not used. Of the information specified in the URL, this method only uses the LDAP host name and port number, the base distinguished name (DN), and the list of attributes to return.
toGet
- LDAP URL specifying the entry to read.
LDAPException
- if the object was not foundpublic static LDAPEntry read(LDAPUrl toGet, LDAPSearchConstraints cons) throws LDAPException
When this method is called, a new connection is created automatically, using the host and port specified in the URL. After finding the entry, the method closes the connection (in other words, it disconnects from the LDAP server).
If the URL specifies a filter and scope, they are not used. Of the information specified in the URL, this method only uses the LDAP host name and port number, the base distinguished name (DN), and the list of attributes to return.
toGet
- LDAP URL specifying the entry to read.
cons
- Constraints specific to the operation.
LDAPException
- if the object was not foundpublic void rename(java.lang.String dn, java.lang.String newRdn, boolean deleteOldRdn) throws LDAPException
dn
- The current distinguished name of the entry.
newRdn
- The new relative distinguished name for the entry.
deleteOldRdn
- If true, the old name is not retained as an
attribute value. If false, the old name is
retained as an attribute value.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void rename(java.lang.String dn, java.lang.String newRdn, boolean deleteOldRdn, LDAPConstraints cons) throws LDAPException
dn
- The current distinguished name of the entry.
newRdn
- The new relative distinguished name for the entry.
deleteOldRdn
- If true, the old name is not retained as an
attribute value. If false, the old name is
retained as an attribute value.
cons
- The constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void rename(java.lang.String dn, java.lang.String newRdn, java.lang.String newParentdn, boolean deleteOldRdn) throws LDAPException
dn
- The current distinguished name of the entry.
newRdn
- The new relative distinguished name for the entry.
newParentdn
- The distinguished name of an existing entry which
is to be the new parent of the entry.
deleteOldRdn
- If true, the old name is not retained as an
attribute value. If false, the old name is
retained as an attribute value.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public void rename(java.lang.String dn, java.lang.String newRdn, java.lang.String newParentdn, boolean deleteOldRdn, LDAPConstraints cons) throws LDAPException
dn
- The current distinguished name of the entry.
newRdn
- The new relative distinguished name for the entry.
newParentdn
- The distinguished name of an existing entry which
is to be the new parent of the entry.
deleteOldRdn
- If true, the old name is not retained as an
attribute value. If false, the old name is
retained as an attribute value.
cons
- The constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue rename(java.lang.String dn, java.lang.String newRdn, boolean deleteOldRdn, LDAPResponseQueue queue) throws LDAPException
dn
- The current distinguished name of the entry.
newRdn
- The new relative distinguished name for the entry.
deleteOldRdn
- If true, the old name is not retained as an
attribute value. If false, the old name is
retained as an attribute value.
queue
- The queue for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue rename(java.lang.String dn, java.lang.String newRdn, boolean deleteOldRdn, LDAPResponseQueue queue, LDAPConstraints cons) throws LDAPException
dn
- The current distinguished name of the entry.
newRdn
- The new relative distinguished name for the entry.
deleteOldRdn
- If true, the old name is not retained as an
attribute value. If false, the old name is
retained as an attribute value.
queue
- The queue for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
cons
- The constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue rename(java.lang.String dn, java.lang.String newRdn, java.lang.String newParentdn, boolean deleteOldRdn, LDAPResponseQueue queue) throws LDAPException
dn
- The current distinguished name of the entry.
newRdn
- The new relative distinguished name for the entry.
newParentdn
- The distinguished name of an existing entry which
is to be the new parent of the entry.
deleteOldRdn
- If true, the old name is not retained as an
attribute value. If false, the old name is
retained as an attribute value.
queue
- The queue for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPResponseQueue rename(java.lang.String dn, java.lang.String newRdn, java.lang.String newParentdn, boolean deleteOldRdn, LDAPResponseQueue queue, LDAPConstraints cons) throws LDAPException
dn
- The current distinguished name of the entry.
newRdn
- The new relative distinguished name for the entry.
newParentdn
- The distinguished name of an existing entry which
is to be the new parent of the entry.
deleteOldRdn
- If true, the old name is not retained as an
attribute value. If false, the old name is
retained as an attribute value.
queue
- The queue for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
cons
- The constraints specific to the operation.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPSearchResults search(java.lang.String base, int scope, java.lang.String filter, java.lang.String[] attrs, boolean typesOnly) throws LDAPException
base
- The base distinguished name to search from.
scope
- The scope of the entries to search. The following
are the valid options:
filter
- Search filter specifying the search criteria.
attrs
- Names of attributes to retrieve.
typesOnly
- If true, returns the names but not the values of
the attributes found. If false, returns the
names and values for attributes found.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPSearchResults search(java.lang.String base, int scope, java.lang.String filter, java.lang.String[] attrs, boolean typesOnly, LDAPSearchConstraints cons) throws LDAPException
As part of the search constraints, the method allows specifying whether or not the results are to be delivered all at once or in smaller batches. If specified that the results are to be delivered in smaller batches, each iteration blocks only until the next batch of results is returned.
base
- The base distinguished name to search from.
scope
- The scope of the entries to search. The following
are the valid options:
filter
- The search filter specifying the search criteria.
attrs
- The names of attributes to retrieve.
typesOnly
- If true, returns the names but not the values of
the attributes found. If false, returns the
names and values for attributes found.
cons
- The constraints specific to the search.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPSearchQueue search(java.lang.String base, int scope, java.lang.String filter, java.lang.String[] attrs, boolean typesOnly, LDAPSearchQueue queue) throws LDAPException
base
- The base distinguished name to search from.
scope
- The scope of the entries to search. The following
are the valid options:
filter
- Search filter specifying the search criteria.
attrs
- Names of attributes to retrieve.
typesOnly
- If true, returns the names but not the values of
the attributes found. If false, returns the
names and values for attributes found.
queue
- Handler for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPSearchQueue search(java.lang.String base, int scope, java.lang.String filter, java.lang.String[] attrs, boolean typesOnly, LDAPSearchQueue queue, LDAPSearchConstraints cons) throws LDAPException
base
- The base distinguished name to search from.
scope
- The scope of the entries to search. The following
are the valid options:
filter
- The search filter specifying the search criteria.
attrs
- The names of attributes to retrieve.
typesOnly
- If true, returns the names but not the values of
the attributes found. If false, returns the
names and values for attributes found.
queue
- The queue for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
cons
- The constraints specific to the search.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public static LDAPSearchResults search(LDAPUrl toGet) throws LDAPException
toGet
- The LDAP URL specifying the entry to read.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public static LDAPSearchResults search(LDAPUrl toGet, LDAPSearchConstraints cons) throws LDAPException
When this method is called, a new connection is created automatically, using the host and port specified in the URL. After all search results have been received from the server, the method closes the connection (in other words, it disconnects from the LDAP server).
As part of the search constraints, a choice can be made as to whether to have the results delivered all at once or in smaller batches. If the results are to be delivered in smaller batches, each iteration blocks only until the next batch of results is returned.
toGet
- LDAP URL specifying the entry to read.
cons
- The constraints specific to the search.
LDAPException
- A general exception which includes an error
message and an LDAP error code.public LDAPMessageQueue sendRequest(LDAPMessage request, LDAPMessageQueue queue) throws LDAPException
The specified the LDAP request is sent to the directory server
associated with this connection using default constraints. An LDAP
request object is a subclass LDAPMessage
with the operation
type set to one of the request types. You can build a request by using
the request classes found in this package
You should note that, since LDAP requests sent to the server using sendRequest are asynchronous, automatic referral following does not apply to these requests.
request
- The LDAP request to send to the directory server.queue
- The queue for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.
LDAPException
- A general exception which includes an error
message and an LDAP error code.LDAPMessage.getType()
,
LDAPMessage.isRequest()
public LDAPMessageQueue sendRequest(LDAPMessage request, LDAPMessageQueue queue, LDAPConstraints cons) throws LDAPException
The specified the LDAP request is sent to the directory server
associated with this connection. An LDAP request object is an
LDAPMessage
with the operation type set to one of the request
types. You can build a request by using the request classes found in this
package
You should note that, since LDAP requests sent to the server using sendRequest are asynchronous, automatic referral following does not apply to these requests.
request
- The LDAP request to send to the directory server.queue
- The queue for messages returned from a server in
response to this request. If it is null, a
queue object is created internally.cons
- The constraints that apply to this request
LDAPException
- A general exception which includes an error
message and an LDAP error code.LDAPMessage.getType()
,
LDAPMessage.isRequest()
public LDAPSchema fetchSchema(java.lang.String schemaDN) throws LDAPException
The schema DN for a particular entry is obtained by calling the getSchemaDN method of LDAPConnection
schemaDN
- The schema DN used to fetch the schema.
LDAPException
- This exception occurs if the schema entry
cannot be retrieved with this connection.getSchemaDN()
,
getSchemaDN(String)
public java.lang.String getSchemaDN() throws LDAPException
The DN can be used with the methods fetchSchema and modify to retreive
and extend schema definitions. The schema entry is located by reading
subschemaSubentry attribute of the root DSE. This is equivalent to
calling getSchemaDN(String)
with the DN parameter as an empty
string: getSchemaDN("")
.
LDAPException
- This exception occurs if the schema DN
cannot be retrieved, or if the subschemaSubentry attribute associated
with the root DSE contains multiple values.fetchSchema(java.lang.String)
,
modify(java.lang.String, com.novell.ldap.LDAPModification)
public java.lang.String getSchemaDN(java.lang.String dn) throws LDAPException
The DN can be used with the methods fetchSchema and modify to retreive and extend schema definitions. Reads the subschemaSubentry of the entry specified.
dn
- Distinguished Name of any entry. The subschemaSubentry
attribute is queried from this entry.
dn
.
LDAPException
- This exception occurs if a null or empty
value is passed as dn, if the subschemasubentry attribute cannot
be retrieved, or the subschemasubentry contains multiple values.fetchSchema(java.lang.String)
,
modify(java.lang.String, com.novell.ldap.LDAPModification)
|
LDAP Classes Implements Java LDAP |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |