gnu.inet.ldap
Class LDAPConnection
An LDAPv3 client.
This client is still experimental, please contact
Chris Burdess if you want to help out
with it.
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.
|
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.
|
DEFAULT_PORT
public static final int DEFAULT_PORT
The default LDAP port.
- 389
DEREF_ALWAYS
public static final int DEREF_ALWAYS
Dereference aliases both in searching and in locating the base object
of the search.
- 3
DEREF_FINDING_BASE_OBJ
public static final int DEREF_FINDING_BASE_OBJ
Dereference aliases in locating the base object of the search, but not
when searching subordinates of the base object.
- 2
DEREF_IN_SEARCHING
public static final int DEREF_IN_SEARCHING
Dereference aliases in subordinates of the base object in searching,
but not in locating the base object of the search.
- 1
DEREF_NEVER
public static final int DEREF_NEVER
Do not dereference aliases in searching or in locating the base object
of the search.
- 0
LDAPConnection
public LDAPConnection(String host)
throws IOException
Creates a new LDAP connection to the specified host, using the default
LDAP port.
host
- the host
LDAPConnection
public LDAPConnection(String host,
int port)
throws IOException
Creates a new LDAP connection to the specified host and port.
host
- the hostport
- the port
LDAPConnection
public LDAPConnection(String host,
int port,
int connectionTimeout,
int timeout)
throws IOException
Creates a new LDAP connection to the specified host, port, and timeouts.
host
- the hostport
- the portconnectionTimeout
- the connection timeout in mstimeout
- the socket I/O timeout in ms
add
public LDAPResult add(String name,
AttributeValues[] attributes)
throws IOException
Requests the addition of a new entry into the directory.
name
- the LDAP DN of the new entryattributes
- a sequence of attributes to assign to the new entry
bind
public LDAPResult bind(String name,
String mechanism,
byte[] credentials,
Control controls)
throws IOException
Initiates a bind operation to authenticate the client to the server.
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 use
- the LDAP result
modify
public LDAPResult modify(String name,
Modification modifications)
throws IOException
Issues a modify request.
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 executed
Modification
modifyDN
public LDAPResult modifyDN(String name,
String newRDN,
boolean deleteOldRDN,
String newSuperior)
throws IOException
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.
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 entry
search
public LDAPResult search(String name,
int scope,
int derefAliases,
int sizeLimit,
int timeLimit,
boolean typesOnly,
String filter,
String[] attributes,
Control controls,
ResultHandler handler)
throws IOException
Issues a search request.
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 results
- the LDAP result
setVersion
public void setVersion(int version)
Sets the version of LDAP to use.
This implementation supports versions 2 and 3.
version
- the LDAP version
unbind
public void unbind()
throws IOException
Issues an unbind request. This indicates to the server that the client
has no more requests to issue and will terminate the connection. After
invoking this method, no further methods may be invoked.
* LDAPConnection.java
* Copyright (C) 2004 The Free Software Foundation
*
* This file is part of GNU inetlib, a library.
*
* GNU inetlib is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GNU inetlib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Linking this library statically or dynamically with other modules is
* making a combined work based on this library. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* As a special exception, the copyright holders of this library give you
* permission to link this library with independent modules to produce an
* executable, regardless of the license terms of these independent
* modules, and to copy and distribute the resulting executable under
* terms of your choice, provided that you also meet, for each linked
* independent module, the terms and conditions of the license of that
* module. An independent module is a module which is not derived from
* or based on this library. If you modify this library, you may extend
* this exception to your version of the library, but you are not
* obliged to do so. If you do not wish to do so, delete this
* exception statement from your version.