edu.vt.middleware.ldap
public class Ldap extends AbstractLdap<LdapConfig> implements java.io.Serializable
Ldap contains functions for basic interaction with an LDAP.
Methods are provided for connecting, binding, querying and updating.| Modifier and Type | Class and Description |
|---|---|
static class |
Ldap.AttributeModification
Enum to define the type of attribute modification.
|
BINDING_COPY_RESULT_HANDLER, config, connectionHandler, COPY_RESULT_HANDLER, logger, NCP_COPY_RESULT_HANDLER, SR_COPY_RESULT_HANDLER| Constructor and Description |
|---|
Ldap()
Default constructor.
|
Ldap(LdapConfig ldapConfig)
This will create a new
Ldap with the supplied
LdapConfig. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
compare(SearchFilter filter)
This will perform an LDAP compare operation with the supplied filter.
|
boolean |
compare(java.lang.String dn,
SearchFilter filter)
This will perform an LDAP compare operation with the supplied filter and
dn.
|
void |
create(java.lang.String dn,
javax.naming.directory.Attributes attrs)
This will create the supplied dn in the LDAP namespace with the supplied
attributes.
|
void |
delete(java.lang.String dn)
This will delete the supplied dn from the LDAP namespace.
|
javax.naming.directory.Attributes |
getAttributes(java.lang.String dn)
This will return all the attributes associated with the supplied dn.
|
javax.naming.directory.Attributes |
getAttributes(java.lang.String dn,
java.lang.String[] retAttrs)
This will return the matching attributes associated with the supplied dn.
|
javax.naming.directory.Attributes |
getAttributes(java.lang.String dn,
java.lang.String[] retAttrs,
AttributeHandler... handler)
This will return the matching attributes associated with the supplied dn.
|
LdapConfig |
getLdapConfig()
This returns the
LdapConfig of the Ldap. |
java.lang.String[] |
getSaslMechanisms()
This will return a list of SASL mechanisms that this LDAP supports.
|
java.util.Iterator<javax.naming.directory.SearchResult> |
getSchema(java.lang.String dn)
This will return the LDAP schema associated with the supplied dn.
|
java.lang.String[] |
getSupportedControls()
This will return a list of controls that this LDAP supports.
|
java.util.Iterator<javax.naming.NameClassPair> |
list(java.lang.String dn)
This will enumerate the names bounds to the specified context, along with
the class names of objects bound to them.
|
java.util.Iterator<javax.naming.Binding> |
listBindings(java.lang.String dn)
This will enumerate the names bounds to the specified context, along with
the objects bound to them.
|
void |
loadFromProperties()
This will set the config parameters of this
Ldap using the
default properties file, which must be located in your classpath. |
void |
loadFromProperties(java.io.InputStream is)
This will set the config parameters of this
Ldap using the
supplied input stream. |
void |
modifyAttributes(java.lang.String dn,
Ldap.AttributeModification mod,
javax.naming.directory.Attributes attrs)
This will modify the supplied attributes for the supplied value given by
the modification operation.
|
void |
modifyAttributes(java.lang.String dn,
javax.naming.directory.ModificationItem[] mods)
This will modify the supplied dn using the supplied modifications.
|
void |
rename(java.lang.String oldDn,
java.lang.String newDn)
This will rename the supplied dn in the LDAP namespace.
|
java.util.Iterator<javax.naming.directory.SearchResult> |
search(SearchFilter filter)
This will query the LDAP with the supplied filter.
|
java.util.Iterator<javax.naming.directory.SearchResult> |
search(SearchFilter filter,
javax.naming.directory.SearchControls searchControls)
This will query the LDAP with the supplied filter and search controls.
|
java.util.Iterator<javax.naming.directory.SearchResult> |
search(SearchFilter filter,
java.lang.String[] retAttrs)
This will query the LDAP with the supplied filter and return attributes.
|
java.util.Iterator<javax.naming.directory.SearchResult> |
search(java.lang.String dn,
SearchFilter filter)
This will query the LDAP with the supplied dn and filter.
|
java.util.Iterator<javax.naming.directory.SearchResult> |
search(java.lang.String dn,
SearchFilter filter,
javax.naming.directory.SearchControls searchControls)
This will query the LDAP with the supplied dn, filter, and search controls.
|
java.util.Iterator<javax.naming.directory.SearchResult> |
search(java.lang.String dn,
SearchFilter filter,
javax.naming.directory.SearchControls searchControls,
SearchResultHandler... handler)
This will query the LDAP with the supplied dn, filter, search controls, and
search result handler.
|
java.util.Iterator<javax.naming.directory.SearchResult> |
search(java.lang.String dn,
SearchFilter filter,
java.lang.String[] retAttrs)
This will query the LDAP with the supplied dn, filter, and return
attributes.
|
java.util.Iterator<javax.naming.directory.SearchResult> |
search(java.lang.String dn,
SearchFilter filter,
java.lang.String[] retAttrs,
SearchResultHandler... handler)
This will query the LDAP with the supplied dn, filter, return attributes,
and search result handler.
|
java.util.Iterator<javax.naming.directory.SearchResult> |
searchAttributes(javax.naming.directory.Attributes matchAttrs)
This will query the LDAP for the supplied matching attributes.
|
java.util.Iterator<javax.naming.directory.SearchResult> |
searchAttributes(javax.naming.directory.Attributes matchAttrs,
java.lang.String[] retAttrs)
This will query the LDAP for the supplied matching attributes and return
attributes.
|
java.util.Iterator<javax.naming.directory.SearchResult> |
searchAttributes(java.lang.String dn,
javax.naming.directory.Attributes matchAttrs)
This will query the LDAP for the supplied dn and matching attributes.
|
java.util.Iterator<javax.naming.directory.SearchResult> |
searchAttributes(java.lang.String dn,
javax.naming.directory.Attributes matchAttrs,
java.lang.String[] retAttrs)
This will query the LDAP for the supplied dn, matching attributes and
return attributes.
|
java.util.Iterator<javax.naming.directory.SearchResult> |
searchAttributes(java.lang.String dn,
javax.naming.directory.Attributes matchAttrs,
java.lang.String[] retAttrs,
SearchResultHandler... handler)
This will query the LDAP for the supplied dn, matching attributes and
return attributes.
|
void |
setLdapConfig(LdapConfig ldapConfig)
This will set the config parameters of this
Ldap. |
close, compare, connect, finalize, getContext, modifyAttributes, operationRetry, pagedSearch, reconnect, search, toStringpublic Ldap()
public Ldap(LdapConfig ldapConfig)
Ldap with the supplied
LdapConfig.ldapConfig - LdapConfigpublic void setLdapConfig(LdapConfig ldapConfig)
Ldap.setLdapConfig in class AbstractLdap<LdapConfig>ldapConfig - LdapConfigpublic LdapConfig getLdapConfig()
LdapConfig of the Ldap.LdapConfigpublic void loadFromProperties()
Ldap using the
default properties file, which must be located in your classpath.public void loadFromProperties(java.io.InputStream is)
Ldap using the
supplied input stream.is - InputStreampublic boolean compare(SearchFilter filter) throws javax.naming.NamingException
LdapConfig.getBaseDn() is used as the dn to compare. See compare(String, SearchFilter).filter - SearchFilter expression to use for compareboolean - result of compare operationjavax.naming.NamingException - if the LDAP returns an errorpublic boolean compare(java.lang.String dn,
SearchFilter filter)
throws javax.naming.NamingException
dn - String name to comparefilter - SearchFilter expression to use for compareboolean - result of compare operationjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.directory.SearchResult> search(SearchFilter filter) throws javax.naming.NamingException
LdapConfig.getBaseDn() is used as the start point for
searching. Search controls will be created from LdapConfig.getSearchControls(String[]). See search(String,SearchFilter,String[]).filter - SearchFilter expression to use for the searchIterator - of LDAP search resultsjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.directory.SearchResult> search(SearchFilter filter, java.lang.String[] retAttrs) throws javax.naming.NamingException
LdapConfig.getBaseDn() is used as the start point for searching.
Search controls will be created from LdapConfig.getSearchControls(String[]). See search(String,SearchFilter,String[]).filter - SearchFilter expression to use for the searchretAttrs - String[] attributes to returnIterator - of LDAP search resultsjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.directory.SearchResult> search(SearchFilter filter, javax.naming.directory.SearchControls searchControls) throws javax.naming.NamingException
LdapConfig.getBaseDn() is used as the start point for searching.
See search(String,SearchFilter,SearchControls).filter - SearchFilter expression to use for the searchsearchControls - SearchControls to search withIterator - of LDAP search resultsjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.directory.SearchResult> search(java.lang.String dn,
SearchFilter filter)
throws javax.naming.NamingException
LdapConfig.getSearchControls(String[]). See search(String,SearchFilter,String[]).dn - String name to begin search atfilter - SearchFilter expression to use for the searchIterator - of LDAP search resultsjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.directory.SearchResult> search(java.lang.String dn,
SearchFilter filter,
java.lang.String[] retAttrs)
throws javax.naming.NamingException
LdapConfig.getSearchControls(String[]). See search(String,SearchFilter,SearchControls,SearchResultHandler[]).dn - String name to begin search atfilter - SearchFilter expression to use for the searchretAttrs - String[] attributes to returnIterator - of LDAP search resultsjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.directory.SearchResult> search(java.lang.String dn,
SearchFilter filter,
javax.naming.directory.SearchControls searchControls)
throws javax.naming.NamingException
search(String,SearchFilter,SearchControls,SearchResultHandler[]).dn - String name to begin search atfilter - SearchFilter expression to use for the searchsearchControls - SearchControls to search withIterator - of LDAP search resultsjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.directory.SearchResult> search(java.lang.String dn,
SearchFilter filter,
java.lang.String[] retAttrs,
SearchResultHandler... handler)
throws javax.naming.NamingException
LdapConfig.getSearchControls(String[]). See search(
String,SearchFilter,SearchControls,SearchResultHandler...).dn - String name to begin search atfilter - SearchFilter expression to use for the searchretAttrs - String[] attributes to returnhandler - SearchResultHandler[] of handlers to executeIterator - of LDAP search resultsjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.directory.SearchResult> search(java.lang.String dn,
SearchFilter filter,
javax.naming.directory.SearchControls searchControls,
SearchResultHandler... handler)
throws javax.naming.NamingException
LdapConfig.getPagedResultsSize() is
greater than 0, the PagedResultsControl will be invoked. See #search(String,String,Object[],SearchControls,SearchResultHandler[]).dn - String name to begin search atfilter - SearchFilter expression to use for the searchsearchControls - SearchControls to search withhandler - SearchResultHandler[] of handlers to executeIterator - of LDAP search resultsjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.directory.SearchResult> searchAttributes(javax.naming.directory.Attributes matchAttrs)
throws javax.naming.NamingException
LdapConfig.getBaseDn() is used as the
name to search.
See searchAttributes(String, Attributes, String[]).matchAttrs - Attributes attributes to matchIterator - of LDAP search resultsjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.directory.SearchResult> searchAttributes(javax.naming.directory.Attributes matchAttrs,
java.lang.String[] retAttrs)
throws javax.naming.NamingException
LdapConfig.getBaseDn() is used as the name to search.
See searchAttributes(String, Attributes, String[]).matchAttrs - Attributes attributes to matchretAttrs - String[] attributes to returnIterator - of LDAP search resultsjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.directory.SearchResult> searchAttributes(java.lang.String dn,
javax.naming.directory.Attributes matchAttrs)
throws javax.naming.NamingException
searchAttributes(String,
Attributes, String[]).dn - String name to search inmatchAttrs - Attributes attributes to matchIterator - of LDAP search resultsjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.directory.SearchResult> searchAttributes(java.lang.String dn,
javax.naming.directory.Attributes matchAttrs,
java.lang.String[] retAttrs)
throws javax.naming.NamingException
searchAttributes( String, Attributes,
String[], SearchResultHandler[]). This method converts relative DNs to
fully qualified DNs, no post processing is requireddn - String name to search inmatchAttrs - Attributes attributes to matchretAttrs - String[] attributes to returnIterator - of LDAP search resultsjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.directory.SearchResult> searchAttributes(java.lang.String dn,
javax.naming.directory.Attributes matchAttrs,
java.lang.String[] retAttrs,
SearchResultHandler... handler)
throws javax.naming.NamingException
Iterator is a deep copy of the original search
results. If matchAttrs is empty or null then all objects in the target
context are returned. If retAttrs is null then all attributes will be
returned. If retAttrs is an empty array then no attributes will be
returned. See javax.naming.DirContext#search(String, Attributes,
String[]).searchAttributes in class AbstractLdap<LdapConfig>dn - String name to search inmatchAttrs - Attributes attributes to matchretAttrs - String[] attributes to returnhandler - SearchResultHandler[] to post process resultsIterator - of LDAP search resultsjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.NameClassPair> list(java.lang.String dn)
throws javax.naming.NamingException
Iterator is a deep copy of the original search results. See Context.list(String).list in class AbstractLdap<LdapConfig>dn - String LDAP context to listIterator - LDAP search resultjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.Binding> listBindings(java.lang.String dn)
throws javax.naming.NamingException
Iterator is a deep
copy of the original search results. See Context.listBindings(String).listBindings in class AbstractLdap<LdapConfig>dn - String LDAP context to listIterator - LDAP search resultjavax.naming.NamingException - if the LDAP returns an errorpublic javax.naming.directory.Attributes getAttributes(java.lang.String dn)
throws javax.naming.NamingException
getAttributes(String, String[]).dn - String named object in the LDAPAttributesjavax.naming.NamingException - if the LDAP returns an errorpublic javax.naming.directory.Attributes getAttributes(java.lang.String dn,
java.lang.String[] retAttrs)
throws javax.naming.NamingException
getAttributes(String, String[], AttributeHandler[]).dn - String named object in the LDAPretAttrs - String[] attributes to returnAttributesjavax.naming.NamingException - if the LDAP returns an errorpublic javax.naming.directory.Attributes getAttributes(java.lang.String dn,
java.lang.String[] retAttrs,
AttributeHandler... handler)
throws javax.naming.NamingException
javax.naming.DirContext#getAttributes(String, String[]).getAttributes in class AbstractLdap<LdapConfig>dn - String named object in the LDAPretAttrs - String[] attributes to returnhandler - AttributeHandler[] to post process resultsAttributesjavax.naming.NamingException - if the LDAP returns an errorpublic java.util.Iterator<javax.naming.directory.SearchResult> getSchema(java.lang.String dn)
throws javax.naming.NamingException
Iterator is a deep copy of the original search
results. See javax.naming.DirContext#getSchema(String).getSchema in class AbstractLdap<LdapConfig>dn - String named object in the LDAPIterator - LDAP search resultjavax.naming.NamingException - if the LDAP returns an errorpublic void modifyAttributes(java.lang.String dn,
Ldap.AttributeModification mod,
javax.naming.directory.Attributes attrs)
throws javax.naming.NamingException
AbstractLdap.modifyAttributes(String, int, Attributes).dn - String named object in the LDAPmod - AttributeModification modification operationattrs - Attributes attributes to be used for the
operation, may be nulljavax.naming.NamingException - if the LDAP returns an errorpublic void modifyAttributes(java.lang.String dn,
javax.naming.directory.ModificationItem[] mods)
throws javax.naming.NamingException
javax.naming.DirContext#modifyAttributes(String,
ModificationItem[]).modifyAttributes in class AbstractLdap<LdapConfig>dn - String named object in the LDAPmods - ModificationItem[] modificationsjavax.naming.NamingException - if the LDAP returns an errorpublic void create(java.lang.String dn,
javax.naming.directory.Attributes attrs)
throws javax.naming.NamingException
javax.naming.DirContext#createSubcontext(String,
Attributes). Note that the context created by this operation is
immediately closed.create in class AbstractLdap<LdapConfig>dn - String named object in the LDAPattrs - Attributes attributes to be added to this entryjavax.naming.NamingException - if the LDAP returns an errorpublic void rename(java.lang.String oldDn,
java.lang.String newDn)
throws javax.naming.NamingException
Context.rename(String, String).rename in class AbstractLdap<LdapConfig>oldDn - String object to renamenewDn - String new namejavax.naming.NamingException - if the LDAP returns an errorpublic void delete(java.lang.String dn)
throws javax.naming.NamingException
Context.destroySubcontext(String).delete in class AbstractLdap<LdapConfig>dn - String named object in the LDAPjavax.naming.NamingException - if the LDAP returns an errorpublic java.lang.String[] getSaslMechanisms()
throws javax.naming.NamingException
String[] - supported SASL mechanismsjavax.naming.NamingException - if the LDAP returns an errorpublic java.lang.String[] getSupportedControls()
throws javax.naming.NamingException
String[] - supported controlsjavax.naming.NamingException - if the LDAP returns an errorCopyright © 2014. All Rights Reserved.