LDAP Classes
Implements Java LDAP

com.novell.ldap
Class LDAPUrl

java.lang.Object
  extended bycom.novell.ldap.LDAPUrl
All Implemented Interfaces:
java.lang.Cloneable, java.io.Externalizable, java.io.Serializable

public class LDAPUrl
extends java.lang.Object
implements java.lang.Cloneable, java.io.Externalizable

Encapsulates parameters of an LDAP URL query as defined in RFC2255. An LDAPUrl object can be passed to LDAPConnection.search to retrieve search results.

Sample Code: UrlSearch.java

See Also:
LDAPConnection.search(java.lang.String, int, java.lang.String, java.lang.String[], boolean), Serialized Form

Constructor Summary
LDAPUrl()
          This constructor was added to support default Serialization
LDAPUrl(java.lang.String url)
          Constructs a URL object with the specified string as the URL.
LDAPUrl(java.lang.String host, int port, java.lang.String dn)
          Constructs a URL object with the specified host, port, and DN.
LDAPUrl(java.lang.String host, int port, java.lang.String dn, java.lang.String[] attrNames, int scope, java.lang.String filter, java.lang.String[] extensions)
          Constructs an LDAP URL with all fields explicitly assigned, to specify an LDAP search operation.
LDAPUrl(java.lang.String host, int port, java.lang.String dn, java.lang.String[] attrNames, int scope, java.lang.String filter, java.lang.String[] extensions, boolean secure)
          Constructs an LDAP URL with all fields explicitly assigned, including isSecure, to specify an LDAP search operation.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this URL object.
static java.lang.String decode(java.lang.String URLEncoded)
          Decodes a URL-encoded string.
static java.lang.String encode(java.lang.String toEncode)
          Encodes an arbitrary string using the URL encoding rules.
 java.lang.String[] getAttributeArray()
          Returns an array of attribute names specified in the URL.
 java.util.Enumeration getAttributes()
          Returns an enumerator for the attribute names specified in the URL.
 java.lang.String getDN()
          Returns the base distinguished name encapsulated in the URL.
 java.lang.String[] getExtensions()
          Returns any LDAP URL extensions specified, or null if none are specified.
 java.lang.String getFilter()
          Returns the search filter or null if none was specified.
 java.lang.String getHost()
          Returns the name of the LDAP server in the URL.
 int getPort()
          Returns the port number of the LDAP server in the URL.
 int getScope()
          Returns the depth of search.
 boolean isSecure()
          Returns true if the URL is of the type ldaps (LDAP over SSL, a predecessor to startTls)
static java.lang.Object readDSML(java.io.InputStream input)
          This method is used to deserialize the DSML encoded representation of this class.
 void readExternal(java.io.ObjectInput in)
          Reads the serialized object from the underlying input stream.
 java.lang.String toString()
          Returns a valid string representation of this LDAP URL.
 void writeDSML(java.io.OutputStream oout)
          This method does DSML serialization of the instance.
 void writeExternal(java.io.ObjectOutput out)
          Writes the object state to a stream in XML format
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LDAPUrl

public LDAPUrl()
This constructor was added to support default Serialization


LDAPUrl

public LDAPUrl(java.lang.String url)
        throws java.net.MalformedURLException
Constructs a URL object with the specified string as the URL.

Parameters:
url - An LDAP URL string, e.g. "ldap://ldap.example.com:80/dc=example,dc=com?cn, sn?sub?(objectclass=inetOrgPerson)".
Throws:
java.net.MalformedURLException - The specified URL cannot be parsed.

LDAPUrl

public LDAPUrl(java.lang.String host,
               int port,
               java.lang.String dn)
Constructs a URL object with the specified host, port, and DN.

This form is used to create URL references to a particular object in the directory.

Parameters:
host - Host identifier of LDAP server, or null for "localhost".

port - The port number for LDAP server (use LDAPConnection.DEFAULT_PORT for default port).

dn - Distinguished name of the base object of the search.

LDAPUrl

public LDAPUrl(java.lang.String host,
               int port,
               java.lang.String dn,
               java.lang.String[] attrNames,
               int scope,
               java.lang.String filter,
               java.lang.String[] extensions)
Constructs an LDAP URL with all fields explicitly assigned, to specify an LDAP search operation.

Parameters:
host - Host identifier of LDAP server, or null for "localhost".

port - The port number for LDAP server (use LDAPConnection.DEFAULT_PORT for default port).

dn - Distinguished name of the base object of the search.

attrNames - Names or OIDs of attributes to retrieve. Passing a null array signifies that all user attributes are to be retrieved. Passing a value of "*" allows you to specify that all user attributes as well as any specified operational attributes are to be retrieved.

scope - Depth of search (in DN namespace). Use one of SCOPE_BASE, SCOPE_ONE, SCOPE_SUB from LDAPConnection.

filter - The search filter specifying the search criteria.

extensions - Extensions provide a mechanism to extend the functionality of LDAP URLs. Currently no LDAP URL extensions are defined. Each extension specification is a type=value expression, and may be null or empty. The =value part may be omitted. The expression may be prefixed with '!' if it is mandatory for the evaluation of the URL.

LDAPUrl

public LDAPUrl(java.lang.String host,
               int port,
               java.lang.String dn,
               java.lang.String[] attrNames,
               int scope,
               java.lang.String filter,
               java.lang.String[] extensions,
               boolean secure)
Constructs an LDAP URL with all fields explicitly assigned, including isSecure, to specify an LDAP search operation.

Parameters:
host - Host identifier of LDAP server, or null for "localhost".

port - The port number for LDAP server (use LDAPConnection.DEFAULT_PORT for default port).

dn - Distinguished name of the base object of the search.

attrNames - Names or OIDs of attributes to retrieve. Passing a null array signifies that all user attributes are to be retrieved. Passing a value of "*" allows you to specify that all user attributes as well as any specified operational attributes are to be retrieved.

scope - Depth of search (in DN namespace). Use one of SCOPE_BASE, SCOPE_ONE, SCOPE_SUB from LDAPConnection.

filter - The search filter specifying the search criteria. from LDAPConnection: SCOPE_BASE, SCOPE_ONE, SCOPE_SUB.

extensions - Extensions provide a mechanism to extend the functionality of LDAP URLs. Currently no LDAP URL extensions are defined. Each extension specification is a type=value expression, and may be null or empty. The =value part may be omitted. The expression may be prefixed with '!' if it is mandatory for the evaluation of the URL.

secure - If true creates an LDAP URL of the ldaps type
Method Detail

clone

public java.lang.Object clone()
Returns a clone of this URL object.

Returns:
clone of this URL object.

decode

public static java.lang.String decode(java.lang.String URLEncoded)
                               throws java.net.MalformedURLException
Decodes a URL-encoded string.

Any occurences of %HH are decoded to the hex value represented. However, this method does NOT decode "+" into " ".

Parameters:
URLEncoded - String to decode.
Returns:
The decoded string.
Throws:
java.net.MalformedURLException - The URL could not be parsed.

encode

public static java.lang.String encode(java.lang.String toEncode)
Encodes an arbitrary string using the URL encoding rules.

Any illegal characters are encoded as %HH.

Parameters:
toEncode - The string to encode.
Returns:
The URL-encoded string. Comment: An illegal character consists of any non graphical US-ASCII character, Unsafe, or reserved characters.

getAttributeArray

public java.lang.String[] getAttributeArray()
Returns an array of attribute names specified in the URL.

Returns:
An array of attribute names in the URL.

getAttributes

public java.util.Enumeration getAttributes()
Returns an enumerator for the attribute names specified in the URL.

Returns:
An enumeration of attribute names.

getDN

public java.lang.String getDN()
Returns the base distinguished name encapsulated in the URL.

Returns:
The base distinguished name specified in the URL, or null if none.

getExtensions

public java.lang.String[] getExtensions()
Returns any LDAP URL extensions specified, or null if none are specified. Each extension is a type=value expression. The =value part MAY be omitted. The expression MAY be prefixed with '!' if it is mandatory for evaluation of the URL.

Returns:
string array of extensions.

getFilter

public java.lang.String getFilter()
Returns the search filter or null if none was specified.

Returns:
The search filter.

getHost

public java.lang.String getHost()
Returns the name of the LDAP server in the URL.

Returns:
The host name specified in the URL.

getPort

public int getPort()
Returns the port number of the LDAP server in the URL.

Returns:
The port number in the URL.

getScope

public int getScope()
Returns the depth of search. It returns one of the following from LDAPConnection: SCOPE_BASE, SCOPE_ONE, or SCOPE_SUB.

Returns:
The search scope.

isSecure

public boolean isSecure()
Returns true if the URL is of the type ldaps (LDAP over SSL, a predecessor to startTls)

Returns:
whether this is a secure LDAP url or not.

toString

public java.lang.String toString()
Returns a valid string representation of this LDAP URL.

Returns:
The string representation of the LDAP URL.

writeDSML

public void writeDSML(java.io.OutputStream oout)
               throws java.io.IOException
This method does DSML serialization of the instance.

Parameters:
oout - Outputstream where the serialzed data has to be written
Throws:
java.io.IOException - if write fails on OutputStream

readDSML

public static java.lang.Object readDSML(java.io.InputStream input)
                                 throws java.io.IOException
This method is used to deserialize the DSML encoded representation of this class.

Parameters:
input - InputStream for the DSML formatted data.
Returns:
Deserialized form of this class.
Throws:
java.io.IOException - when serialization fails.

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Writes the object state to a stream in XML format

Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - The ObjectOutput stream where the Object in XML format is being written to
Throws:
java.io.IOException - - If I/O errors occur

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Reads the serialized object from the underlying input stream.

Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - The ObjectInput stream where the Serialized Object is being read from
Throws:
java.io.IOException - - If I/O errors occur
java.lang.ClassNotFoundException - - If the class for an object being restored cannot be found.

LDAP Classes
Implements Java LDAP

Copyright © 2002 Novell, Inc. All Rights Reserved.
Novell, Inc.
1800 South Novell Place
Provo, Ut 84606
Phone: (801) 861-5000