org.acegisecurity.ldap
public class LdapTemplate extends java.lang.Object
This is mainly intended to simplify Ldap access within Acegi Security's LDAP-related services.
Modifier and Type | Field and Description |
---|---|
static java.lang.String[] |
NO_ATTRS |
Constructor and Description |
---|
LdapTemplate(InitialDirContextFactory dirContextFactory) |
LdapTemplate(InitialDirContextFactory dirContextFactory,
java.lang.String userDn,
java.lang.String password) |
Modifier and Type | Method and Description |
---|---|
boolean |
compare(java.lang.String dn,
java.lang.String attributeName,
java.lang.Object value)
Performs an LDAP compare operation of the value of an attribute for a particular directory entry.
|
java.lang.Object |
execute(LdapCallback callback) |
boolean |
nameExists(java.lang.String dn) |
java.lang.Object |
retrieveEntry(java.lang.String dn,
LdapEntryMapper mapper,
java.lang.String[] attributesToRetrieve)
Composes an object from the attributes of the given DN.
|
java.util.Set |
searchForSingleAttributeValues(java.lang.String base,
java.lang.String filter,
java.lang.Object[] params,
java.lang.String attributeName)
Performs a search using the supplied filter and returns the union of the values of the named attribute
found in all entries matched by the search.
|
java.lang.Object |
searchForSingleEntry(java.lang.String base,
java.lang.String filter,
java.lang.Object[] params,
LdapEntryMapper mapper)
Performs a search, with the requirement that the search shall return a single directory entry, and uses
the supplied mapper to create the object from that entry.
|
void |
setSearchControls(javax.naming.directory.SearchControls searchControls)
Sets the search controls which will be used for search operations by the template.
|
public LdapTemplate(InitialDirContextFactory dirContextFactory)
public LdapTemplate(InitialDirContextFactory dirContextFactory, java.lang.String userDn, java.lang.String password)
dirContextFactory
- the source of DirContextsuserDn
- the user name to authenticate as when obtaining new contextspassword
- the user's passwordpublic boolean compare(java.lang.String dn, java.lang.String attributeName, java.lang.Object value)
dn
- the entry who's attribute is to be usedattributeName
- the attribute who's value we want to comparevalue
- the value to be checked against the directory valuepublic java.lang.Object execute(LdapCallback callback) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException
public boolean nameExists(java.lang.String dn)
public java.lang.Object retrieveEntry(java.lang.String dn, LdapEntryMapper mapper, java.lang.String[] attributesToRetrieve)
dn
- the directory entry which will be readmapper
- maps the attributes to the required objectattributesToRetrieve
- the named attributes which will be retrieved from the directory entry.public java.util.Set searchForSingleAttributeValues(java.lang.String base, java.lang.String filter, java.lang.Object[] params, java.lang.String attributeName)
base
- the DN to search infilter
- search filter to useparams
- the parameters to substitute in the search filterattributeName
- the attribute who's values are to be retrieved.public java.lang.Object searchForSingleEntry(java.lang.String base, java.lang.String filter, java.lang.Object[] params, LdapEntryMapper mapper)
base
- filter
- params
- mapper
- org.springframework.dao.IncorrectResultSizeDataAccessException
- if no results are found or the search returns more than one
result.public void setSearchControls(javax.naming.directory.SearchControls searchControls)
searchControls
- the SearchControls instance which will be cached in the template.Copyright © 2004-2014 Interface21, Inc. All Rights Reserved.