[BUG] LDIF produced with ldapsearch is not importable with ldapadd due to duplicate data with alternate field names
Author: larsksCreated Sep 3, 2026Updated Sep 4, 2026
Labelsbug
If export a user from lldap using a command like:
ldapsearch -LLL -b dc=example,dc=com -D cn=admin,ou=people,dc=example,dc=com \
-H ldap://localhost:3890/ -x -w "$LDAPPASSWORD" uid=aliceThat produces output like:
dn: uid=alice,ou=people,dc=example,dc=com
cn: Alice User
createtimestamp: 20260903214313Z
entryuuid: 96cecf69-c6d1-3a22-873f-ac19d9ea15d7
first_name: Alice
givenname: Alice
last_name: User
mail: [email protected]
objectclass: inetOrgPerson
objectclass: posixAccount
objectclass: mailAccount
objectclass: person
sn: User
uid: alice
# pagedresults: estimate=1 cookie=If I later on try to import this into a fresh lldap instance, like this:
ldapadd -D cn=admin,ou=people,dc=example,dc=com -H ldap://localhost:3890/ -x -W -f alice.ldifIt will fail like this:
adding new entry "uid=alice,ou=people,dc=example,dc=com"
ldap_add: Operations error (1)
additional info: Could not create user: DatabaseError(
Exec(
SqlxError(
Database(
SqliteError {
code: 1555,
message: "UNIQUE constraint failed: user_attributes.user_attribute_user_id, user_attributes.user_attribute_name",
},
),
),
),
)This is because of the duplicate information in the LDIF output:
first_nameandgivenNamelast_nameandsn
The solution is to delete the first_name and last_name attributes. This behavior is very surprising: I would expect lldap to produce results that it can consume: either by not producing non-standard attributes like first_name and last_name by default, or by ignoring them on input.
Source: lldap/lldap