15

When im trying to import users to LDAP using this command:

ldapadd -x -D "cn=Manager,dc=domain,dc=com" -W -f  /etc/openldap/root.ldif

I have this error:

ldap_add no such object (32) 
          matched dn dc=domain,dc=com

Let me show you the files:

/etc/openldap/domain.ldif

dn: dc=domain,dc=com
dc: domain
description: LDAP Admin
objectClass: dcObject
objectClass: organizationalUnit
ou: rootobject 

dn: ou=People, dc=domain,dc=com
ou: People
description: Users of adminmart
objectClass: organizationalUnit

/etc/openldap/root.ldif

dn: uid=root,ou=People,dc=domain,dc=com
uid: root
cn: Manager
objectClass: account

Someone can help me?

Thanks

PookPook
  • 261
  • 1
  • 2
  • 9
  • Is your base DN actually dc=domain,dc=com? Check `ldapsearch -hlocalhost -x -sbase | grep '^dn:'` or the configuration on your LDAP server. For OpenLDAP, it'll be the "suffix" line in slapd.conf. – Isaac Freeman Feb 18 '14 at 15:34
  • Also, I wouldn't recommend putting root in LDAP. How will you log on to a machine when it can't reach the LDAP server? – Isaac Freeman Feb 18 '14 at 15:35
  • @IsaacFreeman The command not return anything, and the suffix is "suffix: "dc=domain,dc=com" – PookPook Feb 18 '14 at 16:58

2 Answers2

8

I had the same problem doing the same command:

No such object (32)
matched DN: dc=example,dc=com

I checked the LDIF file and all my OUs from LDAP and I was trying to add an entry to an OU that does not exist.

I solved changing the OU on ldif file for one that exist. And all worked fine.

Neil
  • 355
  • 3
  • 9
  • 16
  • 3
    This is a good answer. Perhaps including an example on how to add a new OU to LDAP would improve the answer, as I had to go to the Google machine to find an example of adding an OU to LDAP. – JeremyCanfield Nov 18 '17 at 05:52
  • If you want, you can add the information in order to add a new OU and I will approve it. – Neil Nov 22 '17 at 13:54
  • This can help: https://unix.stackexchange.com/a/535082/28279 – Benoit Duffez Jan 13 '23 at 16:56
2

i had same problem and was pulling my hair out over it, then added new OU to my ldif, like this:

dn: ou=(what your error says that is missing),o=(company name),dc=(company name),dc=country
objectclass: (class type)
objectclass: top
ou: people

just replace info in ()'s matching to yours and it should work!

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
bernie_g
  • 21
  • 1