{"record":{"id":"479282c9c08fe7e8","repo":"pentaho/pentaho-kettle","slug":"ldapconnection-error-add","errorCode":"LDAPConnection.Error.Add","errorMessage":"LDAPConnection.Error.Add","messagePattern":"LDAPConnection\\.Error\\.Add","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/ldap/impl/src/main/java/org/pentaho/di/trans/steps/ldapinput/LDAPConnection.java","lineNumber":343,"sourceCode":"      throw new KettleException( BaseMessages.getString( PKG, \"LDAPConnection.Error.Update\", dn ), e );\n    }\n  }\n\n  public int add( String dn, String[] attributes, String[] values, String multValuedSeparator, boolean checkEntry ) throws KettleException {\n    try {\n      Attributes attrs = buildAttributes( dn, attributes, values, multValuedSeparator );\n      // We had all attributes\n      getInitialContext().modifyAttributes( dn, DirContext.ADD_ATTRIBUTE, attrs );\n      return STATUS_ADDED;\n    } catch ( NameNotFoundException n ) {\n      // The entry is not found\n      if ( checkEntry ) {\n        throw new KettleException(\n          BaseMessages.getString( PKG, \"LDAPConnection.Error.Deleting.NameNotFound\", dn ), n );\n      }\n      return STATUS_SKIPPED;\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"LDAPConnection.Error.Add\", dn ), e );\n    }\n  }\n\n  /**\n   * Insert record in LDAP based on DN\n   *\n   * @param dn\n   *          : Distinguished Name (Key for lookup)\n   * @param attributes\n   *          : contains all the attributes to set for insert\n   * @param values\n   *          : contains all the values for attributes\n   * @param multValuedSeparator\n   *          : multi-valued attributes separator\n   * @throws KettleException\n   */\n  public void insert( String dn, String[] attributes, String[] values, String multValuedSeparator ) throws KettleException {\n    try {","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/ldap/impl/src/main/java/org/pentaho/di/trans/steps/ldapinput/LDAPConnection.java#L325-L361","documentation":"LDAPConnection.add(dn, attributes, values, multValuedSeparator, checkEntry) wraps any non-NameNotFound exception from modifyAttributes(ADD_ATTRIBUTE) in a KettleException with message key 'LDAPConnection.Error.Add' (dn interpolated). Common underlying causes are schema violations (adding a value to a single-valued attribute that already has one), missing attribute definitions, permission denial, or connection failures.","triggerScenarios":"Adding a second value to a single-valued attribute via ADD_ATTRIBUTE; adding an attribute not permitted by the entry's objectClass; bind user lacks write permission; attribute syntax violation (e.g. non-numeric string in a numeric field).","commonSituations":"AD rejecting modifications to system attributes; OpenLDAP schema missing an aux objectClass needed for the attribute; multivalued source data with wrong multValuedSeparator causing malformed values.","solutions":["Read e.getCause() to identify schema vs permission vs syntax problems.","Use update() (REPLACE semantics) instead of add() when the attribute may already hold a value.","Ensure required objectClasses/auxiliary classes are present for the attributes being added.","Grant write ACI to the bind account and validate value syntax against the schema."],"exampleFix":"// before\nconnection.add(dn, new String[]{\"mail\"}, new String[]{mail}, \";\", true); // fails if mail already set\n// after\nconnection.update(dn, new String[]{\"mail\"}, new String[]{mail}, true); // replace semantics","handlingStrategy":"try-catch","validationCode":"// Confirm attribute is multi-valued before using ADD_ATTRIBUTE\nAttributes schema = ctx.getSchema(dn);\nAttribute attrDef = schema.get(\"AttributeTypes\"); // inspect syntax & SINGLE-VALUE flag before add()","typeGuard":null,"tryCatchPattern":"try {\n  connection.add(dn, attrs, vals, \";\", true);\n} catch (KettleException e) {\n  Throwable root = ExceptionUtils.getRootCause(e);\n  if (root instanceof SchemaViolationException || root instanceof AttributeInUseException) {\n    // single-valued attr already set, or attr not allowed: fall back to replace\n    connection.update(dn, attrs, vals, true);\n  } else { throw e; }\n}","preventionTips":["Use update()/REPLACE semantics for attributes that may already have values","Check the multValuedSeparator matches how source data packs multiple values","Ensure required auxiliary objectClasses are present for optional attributes","Review server schema (AD vs OpenLDAP differ) before writing attributes"],"tags":["ldap","kettle","add","schema"],"backgroundTag":"database-write-failed","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"}