Package netscape.ldap

Class LDAPConnection

java.lang.Object
netscape.ldap.LDAPConnection
All Implemented Interfaces:
Serializable, Cloneable, LDAPAsynchronousConnection, LDAPv2, LDAPv3

public class LDAPConnection extends Object implements LDAPv3, LDAPAsynchronousConnection, Cloneable, Serializable
Represents a connection to an LDAP server.

Use objects of this class to perform LDAP operations (such as search, modify, and add) on an LDAP server.

To perform an LDAP operation on a server, you need to follow these steps:

  1. Create a new LDAPConnection object.
  2. Use the connect method to connect to the LDAP server.
  3. Use the authenticate method to authenticate to server.
  4. Perform the LDAP operation.
  5. Use the disconnect method to disconnect from the server when done.

All operations block until completion (with the exception of the search method in which the results may not all return at the same time).

This class also specifies a default set of constraints (such as the maximum length of time to allow for an operation before timing out) which apply to all operations. To get and set these constraints, use the getOption and setOption methods. To override these constraints for an individual operation, define a new set of constraints by creating a LDAPConstraints object and pass the object to the method for the operation. For search operations, additional constraints are defined in LDAPSearchConstraints (a subclass of LDAPConstraints). To override the default search constraints, create an LDAPSearchConstraints object and pass it to the search method.

If you set up your client to follow referrals automatically, an operation that results in a referral will create a new connection to the LDAP server identified in the referral. In order to have your client authenticate to that LDAP server automatically, you need to define a class that implements the LDAPRebind interface. In your definition of the class, you need to define a getRebindAuthentication method that creates an LDAPRebindAuth object containing the distinguished name and password to use for reauthentication.

Most errors that occur raise the same exception (LDAPException). In order to determine the exact problem that occurred, you can retrieve the result code from this exception and compare its value against a set of defined result codes.

Version:
1.0
See Also: