This interface summarizes the basic functionality available in the
Lightweight Directory Access Protocol (LDAP) version 2. (See
RFC 1777
for the definition of the protocol.)
In the general model for this protocol, objects exist under a directory
in a particular server. Objects are identified by unique, hierarchical names
called Distinguished Names, commonly abreviated "DN". An example of a DN:
cn=Barbara Jensen,ou=Product Development,o=Ace Industry,c=us
Objects have attributes, of the form
attributeName = attributeValue(s)
Attribute names must be Strings, and attribute values can be any 8-bit
sequence (Strings or binary values).
DEFAULT_PORT
public static final int DEFAULT_PORT
The default port number for LDAP servers. You can specify
this identifier when calling the LDAPConnection.connect
method to connect to an LDAP server.
- 389
netscape.ldap.LDAPConnection.connect
PROTOCOL_VERSION
public static final int PROTOCOL_VERSION
Option specifying the version of the LDAP protocol
used by your client when interacting with the LDAP server.
If no version is set, the default version is 2. If you
are planning to use LDAP v3 features (such as controls
or extended operations), you should set this version to 3
or specify version 3 as an argument to the authenticate
method of the LDAPConnection
object.
- 17
LDAPConnection.getOption(int)
, LDAPConnection.setOption(int,Object)
, netscape.ldap.LDAPConnection.authenticate(int, java.lang.String, java.lang.String)
REFERRALS_REBIND_PROC
public static final int REFERRALS_REBIND_PROC
Option specifying the object containing the method for
getting authentication information (the distinguished name
and password) used during a referral. For example, when
referred to another LDAP server, your client uses this object
to obtain the DN and password. Your client authenticates to
the LDAP server using this DN and password.
- 9
LDAPConnection.getOption(int)
, LDAPConnection.setOption(int,Object)
, LDAPRebind
, LDAPRebindAuth
SCOPE_BASE
public static final int SCOPE_BASE
Specifies that the scope of a search includes
only the base DN (distinguished name).
- 0
netscape.ldap.LDAPConnection.search(java.lang.String, int, java.lang.String, java.lang.String[], boolean, netscape.ldap.LDAPSearchConstraints)
SCOPE_ONE
public static final int SCOPE_ONE
Specifies that the scope of a search includes
only the entries one level below the base DN (distinguished name).
- 1
netscape.ldap.LDAPConnection.search(java.lang.String, int, java.lang.String, java.lang.String[], boolean, netscape.ldap.LDAPSearchConstraints)
SCOPE_SUB
public static final int SCOPE_SUB
Specifies that the scope of a search includes
the base DN (distinguished name) and all entries at all levels
beneath that base.
- 2
netscape.ldap.LDAPConnection.search(java.lang.String, int, java.lang.String, java.lang.String[], boolean, netscape.ldap.LDAPSearchConstraints)
abandon
public void abandon(LDAPSearchResults results)
throws LDAPException
Notifies the server to not send additional results associated with this
LDAPSearchResults
object, and discards any results already
received.
results
- LDAPSearchResults object returned from a search
LDAPException
- Failed to notify the server.
add
public void add(LDAPEntry entry)
throws LDAPException
Adds an entry to the directory.
entry
- new entry to add to the directory
LDAPException
- Failed to add the entry to the directory.
add
public void add(LDAPEntry entry,
LDAPConstraints cons)
throws LDAPException
Adds an entry to the directory.
entry
- new entry to add to the directorycons
- the constraints set for the add operation
LDAPException
- Failed to add the entry to the directory.
authenticate
public void authenticate(String DN,
String passwd)
throws LDAPException
Authenticates user with the LDAP server.
DN
- distinguished name to use for authenticationpasswd
- password for authentication
LDAPException
- Failed to authenticate to the server.
bind
public void bind(String DN,
String passwd)
throws LDAPException
Authenticates user with the LDAP server.
DN
- distinguished name to use for authenticationpasswd
- password for authentication
LDAPException
- Failed to authenticate to the server.
compare
public boolean compare(String DN,
LDAPAttribute attr)
throws LDAPException
Compares the given entry's attribute value to the specified
attribute value.
DN
- distinguished name of the entry that you want compared
against the specified attribute valueattr
- attribute name and value to use in the comparison
LDAPException
- Failed to perform the comparison.
compare
public boolean compare(String DN,
LDAPAttribute attr,
LDAPConstraints cons)
throws LDAPException
Compares the given entry's attribute value to the specified
attribute value.
DN
- distinguished name of the entry that you want compared
against the specified attribute valueattr
- attribute name and value to use in the comparisoncons
- the constraints set for the compare operation
LDAPException
- Failed to perform the comparison.
connect
public void connect(String host,
int port)
throws LDAPException
Connects to the LDAP server.
host
- hostname of the LDAP serverport
- port number of the LDAP server. To specify the
default port, use DEFAULT_PORT
.
LDAPException
- Failed to connect to the server.
connect
public void connect(String host,
int port,
String dn,
String passwd)
throws LDAPException
Connects and authenticates to the LDAP server.
host
- hostname of the LDAP serverport
- port number of the LDAP server. To specify the
default port, use DEFAULT_PORT
.dn
- distinguished name to use for authenticationpasswd
- password for authentication
LDAPException
- Failed to connect and authenticate to the server.
delete
public void delete(String DN)
throws LDAPException
Removes an entry from the directory.
DN
- distinguished name identifying the entry to remove
LDAPException
- Failed to remove the entry from the directory.
delete
public void delete(String DN,
LDAPConstraints cons)
throws LDAPException
Removes an entry from the directory.
DN
- distinguished name identifying the entry to removecons
- the constraints set for the delete operation
LDAPException
- Failed to remove the entry from the directory.
disconnect
public void disconnect()
throws LDAPException
Disconnects from the LDAP server. Subsequent operational calls
will first try to re-establish the connection to the same LDAP server.
LDAPException
- Failed to disconnect from the server.
getOption
public Object getOption(int option)
throws LDAPException
Retrieves an option that applies to the connection.
The particular meaning may be implementation-dependent.
The standard options are the options described by
the LDAPSearchConstraints
and LDAPConstraints
classes.
LDAPException
- Failed to retrieve the value of the specified option.
modify
public void modify(String DN,
LDAPModification mod)
throws LDAPException
Modifies an attribute of a directory entry.
DN
- distinguished name identifying the entry to modifymod
- the modification to make
LDAPException
- Failed to modify the specified entry.
modify
public void modify(String DN,
LDAPModification mod,
LDAPConstraints cons)
throws LDAPException
Modifies an attribute of a directory entry.
DN
- distinguished name identifying the entry to modifymod
- the modification to makecons
- the constraints set for the modify operation
LDAPException
- Failed to modify the specified entry.
modify
public void modify(String DN,
LDAPModificationSet mods)
throws LDAPException
Modifies the attributes of a directory entry.
DN
- distinguished name identifying the entry to modify
LDAPException
- Failed to modify the specified entry.
modify
public void modify(String DN,
LDAPModificationSet mods,
LDAPConstraints cons)
throws LDAPException
Modifies the attributes of a directory entry.
DN
- distinguished name identifying the entry to modifycons
- the constraints set for the modify operation
LDAPException
- Failed to modify the specified entry.
read
public LDAPEntry read(String DN)
throws LDAPException
Read the entry corresponding to the specified distinguished name (DN).
DN
- distinguished name of the entry to retrieve
LDAPException
- Failed to retrieve the specified entry.
read
public LDAPEntry read(String DN,
attrs[] )
throws LDAPException
Read the entry corresponding to the specified distinguished name (DN),
and retrieve only the specified attributes.
DN
- distinguished name of the entry to retrieve
LDAPException
- Failed to retrieve the specified entry.
read
public LDAPEntry read(String DN,
attrs[] ,
LDAPSearchConstraints cons)
throws LDAPException
Read the entry corresponding to the specified distinguished name (DN),
and retrieve only the specified attributes.
DN
- distinguished name of the entry to retrievecons
- the constraints set for the read operation
LDAPException
- Failed to retrieve the specified entry.
rename
public void rename(String DN,
String newRDN,
boolean deleteOldRDN)
throws LDAPException
Changes the name of an entry in the directory.
DN
- distinguished name (DN) of entrynewRDN
- the new relative distinguished name (RDN) of the entrydeleteOldRDN
- true
if the original RDN should no longer
be an attribute of the entry; false
if it should
LDAPException
- Failed to rename the entry in the directory.
rename
public void rename(String DN,
String newRDN,
boolean deleteOldRDN,
LDAPConstraints cons)
throws LDAPException
Changes the name of an entry in the directory.
DN
- distinguished name (DN) of entrynewRDN
- new relative distinguished name (RDN) of the entrydeleteOldRDN
- specifies whether or not the original RDN remains
as an attribute of the entry. If true
, the original RDN
is no longer an attribute of the entry.cons
- the constraints set for the rename operation
LDAPException
- Failed to rename the entry in the directory.
search
public LDAPSearchResults search(String base,
int scope,
String filter,
String[] attrs,
boolean attrsOnly)
throws LDAPException
Searches for entries in the directory.
base
- starting point for the search in the directory
(distinguished name)scope
- indicates whether the scope of the search includes
only the base DN (equivalent to a read operation), only the entries
one level below the base DN, or all entries at all levels beneath
the base DN (including the base DN itself)filter
- String which describes the search criteria. The format
of the string is described fully in
RFC 1558.attrs
- names of the attributes to return for each matching
directory entry. If null
, all attributes are returned.attrsOnly
- if true
, the search will return only the names of
the attributes (and not their values)
LDAPException
- Failed to complete the requested search.
search
public LDAPSearchResults search(String base,
int scope,
String filter,
String[] attrs,
boolean attrsOnly,
LDAPSearchConstraints cons)
throws LDAPException
Searches for entries in the directory.
base
- starting point for the search in the directory
(distinguished name)scope
- indicates whether the scope of the search includes
only the base DN (equivalent to a read operation), only the entries
one level below the base DN, or all entries at all levels beneath
the base DN (including the base DN itself)filter
- String which describes the search criteria. The format
of the string is described fully in
RFC 1558.attrs
- names of the attributes to return for each matching
directory entry. If null
, all attributes are returned.attrsOnly
- if true
, the search will return only the names of
the attributes (and not their values)cons
- constraints specific to the search (for example, the maximum number
of entries to return or the maximum time to wait for the search operation to complete)
LDAPException
- Failed to complete the requested search.
setOption
public void setOption(int option,
Object value)
throws LDAPException
Sets an option that applies to the connection.
The particular meaning may be implementation-dependent.
The standard options are the options described by
the LDAPSearchConstraints
and LDAPConstraints
classes.
LDAPException
- Failed to set the specified option.