40             ServicesLogger.LOGGER.unknownAction(action);
    44         Context ldapContext = null;
    46             Hashtable<String, Object> env = 
new Hashtable<String, Object>();
    47             env.put(Context.INITIAL_CONTEXT_FACTORY, 
"com.sun.jndi.ldap.LdapCtxFactory");
    49             if (connectionUrl == null) {
    50                 logger.errorf(
"Unknown connection URL");
    53             env.put(Context.PROVIDER_URL, connectionUrl);
    56                 env.put(Context.SECURITY_AUTHENTICATION, 
"simple");
    59                     logger.error(
"Unknown bind DN");
    62                 env.put(Context.SECURITY_PRINCIPAL, bindDn);
    64                 char[] bindCredentialChar = null;
    65                 if (bindCredential != null) {
    66                     bindCredentialChar = bindCredential.toCharArray();
    68                 env.put(Context.SECURITY_CREDENTIALS, bindCredentialChar);
    71             LDAPConstants.setTruststoreSpiIfNeeded(useTruststoreSpi, connectionUrl, env);
    73             if (connectionTimeout != null && !connectionTimeout.isEmpty()) {
    74                 env.put(
"com.sun.jndi.ldap.connect.timeout", connectionTimeout);
    77             ldapContext = 
new InitialLdapContext(env, null);
    79         } 
catch (Exception ne) {
    80             String errorMessage = (
TEST_AUTHENTICATION.equals(action)) ? 
"Error when authenticating to LDAP: " : 
"Error when connecting to LDAP: ";
    81             ServicesLogger.LOGGER.errorAuthenticating(ne, errorMessage + ne.getMessage());
    84             if (ldapContext != null) {
    87                 } 
catch (NamingException ne) {
    88                     ServicesLogger.LOGGER.errorClosingLDAP(ne);
 static final Logger logger
Definition: LDAPConnectionTestManager.java:33
 
static final String TEST_AUTHENTICATION
Definition: LDAPConnectionTestManager.java:36
 
static final String TEST_CONNECTION
Definition: LDAPConnectionTestManager.java:35