public class LdapSearchUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
canConnectToLdapDirectory(LdapConfiguration config)
Tests whether a connection to the LDAP directory is possible.
|
static org.springframework.ldap.core.support.LdapContextSource |
createLdapContext(LdapConfiguration config,
LdapAttributesMapper<?> mapper)
Creates an LDAP context
|
static org.springframework.ldap.core.support.LdapContextSource |
createLdapContext(LdapConfiguration config,
String[] binaryAttributes) |
static String[] |
getServerUrls(LdapConfiguration config)
Tries to find all available urls.
|
static <T> T |
retrieveEntry(org.springframework.ldap.core.support.LdapContextSource contextFactory,
String dn,
String searchFilter,
String[] attributesToReturn,
Collection<LdapSearchBaseDefinition> searchBaseDefs,
LdapAttributesMapper<T> mapper)
Retrieve an entry with the named attributes from the LDAP directory and convert it with the
provided attributes mapper.
|
public static boolean canConnectToLdapDirectory(LdapConfiguration config)
config - the LDAP configurationpublic static org.springframework.ldap.core.support.LdapContextSource createLdapContext(LdapConfiguration config, LdapAttributesMapper<?> mapper)
config - the LDAP configurationmapper - the attributes mapperpublic static org.springframework.ldap.core.support.LdapContextSource createLdapContext(LdapConfiguration config, String[] binaryAttributes) throws NamingException
config - the ldap configurationbinaryAttributes - optional array of attributes to be returned as binary. This argument need not to
be provided if the context is not intended to retrieve entries.NamingException - Exceptionpublic static String[] getServerUrls(LdapConfiguration config) throws NamingException
config - The config.NamingException - Exception.public static <T> T retrieveEntry(org.springframework.ldap.core.support.LdapContextSource contextFactory,
String dn,
String searchFilter,
String[] attributesToReturn,
Collection<LdapSearchBaseDefinition> searchBaseDefs,
LdapAttributesMapper<T> mapper)
throws org.springframework.dao.DataAccessException,
LdapAttributeMappingException
contextFactory - context factory to usedn - the DN of the entry to retrievesearchFilter - the searchFilter the entry must adhere toattributesToReturn - the attributes to fetchsearchBaseDefs - search base definitions to assert that the DN conforms to at least one of the
search basesorg.springframework.dao.DataAccessException - in case of access problems while communicating with the repositoryLdapAttributeMappingException - in case the entry cannot be convertedCopyright © 2019 Communote team. All rights reserved.