public class LDAPConnection extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_PORT
The default LDAP port.
|
static int |
DEREF_ALWAYS
Dereference aliases both in searching and in locating the base object
of the search.
|
static int |
DEREF_FINDING_BASE_OBJ
Dereference aliases in locating the base object of the search, but not
when searching subordinates of the base object.
|
static int |
DEREF_IN_SEARCHING
Dereference aliases in subordinates of the base object in searching,
but not in locating the base object of the search.
|
static int |
DEREF_NEVER
Do not dereference aliases in searching or in locating the base object
of the search.
|
protected String |
host |
protected int |
port |
static int |
SCOPE_BASE_OBJECT |
static int |
SCOPE_SINGLE_LEVEL |
static int |
SCOPE_WHOLE_SUBTREE |
protected int |
version |
| Constructor and Description |
|---|
LDAPConnection(String host)
Creates a new LDAP connection to the specified host, using the default
LDAP port.
|
LDAPConnection(String host,
int port)
Creates a new LDAP connection to the specified host and port.
|
LDAPConnection(String host,
int port,
int connectionTimeout,
int timeout)
Creates a new LDAP connection to the specified host, port, and timeouts.
|
| Modifier and Type | Method and Description |
|---|---|
LDAPResult |
add(String name,
AttributeValues[] attributes)
Requests the addition of a new entry into the directory.
|
LDAPResult |
bind(String name,
String mechanism,
byte[] credentials,
Control[] controls)
Initiates a bind operation to authenticate the client to the server.
|
LDAPResult |
delete(String name)
Requests the removal of an entry from the directory.
|
LDAPResult |
modify(String name,
Modification[] modifications)
Issues a modify request.
|
LDAPResult |
modifyDN(String name,
String newRDN,
boolean deleteOldRDN,
String newSuperior)
Changes the leftmost(least significant) component of the name of an
entry in the directory, or move a subtree of entries to a new location
in the directory.
|
LDAPResult |
search(String name,
int scope,
int derefAliases,
int sizeLimit,
int timeLimit,
boolean typesOnly,
String filter,
String[] attributes,
Control[] controls,
ResultHandler handler)
Issues a search request.
|
void |
setVersion(int version)
Sets the version of LDAP to use.
|
void |
unbind()
Issues an unbind request.
|
public static final int DEFAULT_PORT
public static final int SCOPE_BASE_OBJECT
public static final int SCOPE_SINGLE_LEVEL
public static final int SCOPE_WHOLE_SUBTREE
public static final int DEREF_NEVER
public static final int DEREF_IN_SEARCHING
public static final int DEREF_FINDING_BASE_OBJ
public static final int DEREF_ALWAYS
protected String host
protected int port
protected int version
public LDAPConnection(String host) throws IOException
host - the hostIOExceptionpublic LDAPConnection(String host, int port) throws IOException
host - the hostport - the portIOExceptionpublic LDAPConnection(String host, int port, int connectionTimeout, int timeout) throws IOException
host - the hostport - the portconnectionTimeout - the connection timeout in mstimeout - the socket I/O timeout in msIOExceptionpublic void setVersion(int version)
version - the LDAP versionpublic LDAPResult bind(String name, String mechanism, byte[] credentials, Control[] controls) throws IOException
name - the LDAP DN to authenticate to, or null for
anonymous bindingmechanism - the SASL mechanism to use, or null for
simple authenticationcredentials - the security credentials to useIOExceptionpublic void unbind()
throws IOException
IOExceptionpublic LDAPResult search(String name, int scope, int derefAliases, int sizeLimit, int timeLimit, boolean typesOnly, String filter, String[] attributes, Control[] controls, ResultHandler handler) throws IOException
name - the LDAP DN that is the base object entry relative to which
the search is to be performedscope - the search scope, one of the SCOPE_* constantsderefAliases - whether to dereference aliases, one of the DEREF_*
constantssizeLimit - the maximum number of entries to return, or 0 for no
restrictiontimeLimit - the maximum time in seconds permitted for the search,
or 0 for no restrictiontypesOnly - whether to return only attribute types(true) or both
attribute types and values(false)filter - the search filter in RFC2254 formatattributes - the IDs of the attributes to returncontrols - the request controlshandler - the result handler to receive notification of resultsIOExceptionpublic LDAPResult modify(String name, Modification[] modifications) throws IOException
name - the LDAP DN of the object to be modified(alias
dereferencing will not be performed)modifications - a sequence of modifications to be executed
to be executedIOExceptionModificationpublic LDAPResult add(String name, AttributeValues[] attributes) throws IOException
name - the LDAP DN of the new entryattributes - a sequence of attributes to assign to the new entryIOExceptionpublic LDAPResult delete(String name) throws IOException
name - the LDAP DN of the entry to removeIOExceptionpublic LDAPResult modifyDN(String name, String newRDN, boolean deleteOldRDN, String newSuperior) throws IOException
name - the LDAP DN of the entry to be changednewRDN - the RDN that will form the leftmost component of the new
name of the entrydeleteOldRDN - if false, the old RDN values will be retained as
attributes of the entry, otherwise they are deleted from the entrynewSuperior - if non-null, the DN of the entry to become the
immediate superior of the existing entryIOExceptionCopyright © 2017. All rights reserved.