{"record":{"id":"ad851c08286d2747","repo":"pentaho/pentaho-kettle","slug":"ldapinput-exception-errorconnecting","errorCode":"LDAPinput.Exception.ErrorConnecting","errorMessage":"LDAPinput.Exception.ErrorConnecting","messagePattern":"LDAPinput\\.Exception\\.ErrorConnecting","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"critical","filePath":"plugins/ldap/impl/src/main/java/org/pentaho/di/trans/steps/ldapinput/LdapProtocol.java","lineNumber":155,"sourceCode":"  }\n\n  public final void connect( String username, String password ) throws KettleException {\n    Hashtable<String, String> env = new Hashtable<String, String>();\n    setupEnvironment( env, username, password );\n    try {\n      /* Establish LDAP association */\n      doConnect( username, password );\n\n      if ( log.isBasic() ) {\n        log.logBasic( BaseMessages.getString( PKG, \"LDAPInput.Log.ConnectedToServer\", hostname, Const.NVL(\n          username, \"\" ) ) );\n      }\n      if ( log.isDetailed() ) {\n        log.logDetailed( BaseMessages.getString( PKG, \"LDAPInput.ClassUsed.Message\", ctx.getClass().getName() ) );\n      }\n\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"LDAPinput.Exception.ErrorConnecting\", e\n        .getMessage() ), e );\n    }\n  }\n\n  public void close() throws KettleException {\n    if ( ctx != null ) {\n      try {\n        ctx.close();\n        if ( log.isBasic() ) {\n          log.logBasic( BaseMessages.getString( PKG, \"LDAPInput.log.Disconnection.Done\" ) );\n        }\n      } catch ( Exception e ) {\n        log.logError( BaseMessages.getString( PKG, \"LDAPInput.Exception.ErrorDisconecting\", e.toString() ) );\n        log.logError( Const.getStackTracker( e ) );\n      } finally {\n        ctx = null;\n      }\n    }","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/ldap/impl/src/main/java/org/pentaho/di/trans/steps/ldapinput/LdapProtocol.java#L137-L173","documentation":"Thrown by LdapProtocol.connect() when establishing the LDAP connection via the configured directory context (InitialLdapContext) fails with any Exception. The original message from the JNDI/LDAP layer is embedded, so the real reason (wrong host/port, bad credentials, TLS failure, DNS) is in the cause. The step cannot proceed without a connection to the directory server.","triggerScenarios":"new InitialLdapContext(env, null) inside connect() throws: invalid LDAP URL/host/port, authentication bind failure, SSL/TLS handshake error, or naming exception (host not found).","commonSituations":"Typo in hostname or port; LDAP server firewall blocks 389/636; wrong bind DN or password; using ldaps:// without importing the server certificate into the truststore; DNS resolution failure.","solutions":["Read the cause message: 'Connection refused' = wrong host/port/firewall; 'Invalid credentials' = fix bind DN/password","Test the server with ldapsearch or ldapmodify from the same host to isolate network issues","If using LDAPS, import the server certificate into the JVM truststore or configure the step's trust store (see CustomSocketFactory)","Verify the LDAP URL format, e.g. ldap://host:389 or ldaps://host:636"],"exampleFix":"// before (in step dialog)\nHost: ldp-server1, Port: 636, Use encryption: yes\n// after\nHost: ldap-server1.example.com, Port: 636, Use encryption: yes (with server cert in truststore)","handlingStrategy":"try-catch","validationCode":"// Pre-check connectivity before running the transformation\ntry (Socket s = new Socket()) {\n  s.connect(new InetSocketAddress(host, port), 5000); // host=ldap.example.com, port=636\n}","typeGuard":null,"tryCatchPattern":"try {\n  runTransformation();\n} catch (KettleException e) {\n  // message contains 'LDAPinput.Exception.ErrorConnecting' + cause message\n  log.error(\"LDAP connect failed: \" + e.getCause().getMessage(), e.getCause());\n  // route: Connection refused -> host/port; Invalid credentials -> bind DN/password;\n  // SSLHandshakeException -> import server certificate\n}","preventionTips":["Verify host/port/firewall (389/636) before deploying","Test bind credentials with ldapsearch","Import LDAPS server certificates into the JVM truststore","Use fully qualified hostnames and confirm DNS resolution"],"tags":["ldap","connection","jndi"],"backgroundTag":"connection-refused","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}