public final class LdapUrl extends Object
"ldap[s]://" [ hostName [":" portNumber] ] "/" distinguishedName ["?" attributeList ["?" scope "?" filterString ] ]Where:
hostName
and portNumber
identify
the location of the LDAP server.
distinguishedName
is the name of an entry within the
given directory (the entry represents the starting point of the search).
attributeList
contains a list of attributes to
retrieve (if null, fetch all attributes). This is a comma-delimited list of
attribute names.
scope
is one of the following:
base
indicates that this is a search only for the specified
entry
one
indicates that this is a search for matching entries one
level under the specified entry (and not including the entry itself)
sub
indicates that this is a search for matching entries at
all levels under the specified entry (including the entry itself)
subordinates
indicates that this is a search for matching
entries all levels under the specified entry (excluding the entry itself)
scope
is base
by default.
filterString
is a human-readable representation of
the search criteria. If no filter is provided, then a default of "
(objectClass=*)
" should be assumed.
%HH
, where HH
represent the two hex
digits which correspond to the ASCII value of the character. This encoding is
only legal (or necessary) on the DN and filter portions of the URL.
Note that this class does not implement extensions.
Constructor and Description |
---|
LdapUrl(boolean isSecured,
String host,
Integer port,
Dn name)
Creates a new LDAP URL referring to a single entry on the specified
server.
|
LdapUrl(boolean isSecured,
String host,
Integer port,
Dn name,
SearchScope scope,
Filter filter,
String... attributes)
Creates a new LDAP URL including the full set of parameters for a search
request.
|
Modifier and Type | Method and Description |
---|---|
SearchRequest |
asSearchRequest()
Creates a new search request containing the parameters of this LDAP URL.
|
boolean |
equals(Object o) |
List<String> |
getAttributes()
Returns an unmodifiable list containing the attributes to be included
with each entry that matches the search criteria.
|
Filter |
getFilter()
Returns the search filter associated with this LDAP URL.
|
String |
getHost()
Returns the name or IP address in dotted format of the LDAP server
referenced by this LDAP URL.
|
Dn |
getName()
Returns the distinguished name of the base entry relative to which the
search is to be performed.
|
int |
getPort()
Returns the port number of the LDAP server referenced by this LDAP URL.
|
SearchScope |
getScope()
Returns the search scope associated with this LDAP URL.
|
int |
hashCode() |
boolean |
isSecure()
Returns
true if this LDAP URL should use LDAPS or false
if it should use LDAP. |
String |
toString() |
static LdapUrl |
valueOf(String url)
Parses the provided LDAP string representation of an LDAP URL using the
default schema.
|
static LdapUrl |
valueOf(String url,
Schema schema)
Parses the provided LDAP string representation of an LDAP URL using the
provided schema.
|
public LdapUrl(boolean isSecured, String host, Integer port, Dn name)
(objectClass=*)
.isSecured
- true
if this LDAP URL should use LDAPS or
false
if it should use LDAP.host
- The name or IP address in dotted format of the LDAP server.
For example, ldap.server1.com
or
192.202.185.90
. Use null
for the local host.port
- The port number of the LDAP server, or null
to use the
default port (389 for LDAP and 636 for LDAPS).name
- The distinguished name of the base entry relative to which the
search is to be performed, or null
to specify the root
DSE.LocalizedIllegalArgumentException
- If port
was less than 1 or greater than 65535.public LdapUrl(boolean isSecured, String host, Integer port, Dn name, SearchScope scope, Filter filter, String... attributes)
isSecured
- true
if this LDAP URL should use LDAPS or
false
if it should use LDAP.host
- The name or IP address in dotted format of the LDAP server.
For example, ldap.server1.com
or
192.202.185.90
. Use null
for the local host.port
- The port number of the LDAP server, or null
to use the
default port (389 for LDAP and 636 for LDAPS).name
- The distinguished name of the base entry relative to which the
search is to be performed, or null
to specify the root
DSE.scope
- The search scope, or null
to specify base scope.filter
- The search filter, or null
to specify the filter
(objectClass=*)
.attributes
- The list of attributes to be included in the search results.LocalizedIllegalArgumentException
- If port
was less than 1 or greater than 65535.public static LdapUrl valueOf(String url)
url
- The LDAP string representation of an LDAP URL.LocalizedIllegalArgumentException
- If url
is not a valid LDAP string representation of
an LDAP URL.NullPointerException
- If url
was null
.public static LdapUrl valueOf(String url, Schema schema)
url
- The LDAP string representation of an LDAP URL.schema
- The schema to use when parsing the LDAP URL.LocalizedIllegalArgumentException
- If url
is not a valid LDAP string representation of
an LDAP URL.NullPointerException
- If url
or schema
was null
.public SearchRequest asSearchRequest()
public List<String> getAttributes()
public Filter getFilter()
public String getHost()
ldap.server1.com
or
192.202.185.90
. Use null
for the local host.public Dn getName()
public int getPort()
public SearchScope getScope()
public boolean isSecure()
true
if this LDAP URL should use LDAPS or false
if it should use LDAP.true
if this LDAP URL should use LDAPS or false
if it should use LDAP.Copyright 2010-2022 ForgeRock AS.