ldapopenldapslapd

How to add OU in LDAP?


I have done LDAP setup on ubuntu, using apt install slapd ldap-utils

after doing all setup/configuration, added one test user also and here I get:

$ ldapsearch -x -b "dc=param,dc=co,dc=in"
# extended LDIF
#
# LDAPv3
# base <dc=param,dc=co,dc=in> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#

# param.co.in
dn: dc=param,dc=co,dc=in
objectClass: top
objectClass: dcObject
objectClass: organization
o: param
dc: param

# admin, param.co.in
dn: cn=admin,dc=param,dc=co,dc=in
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP administrator

# testuser, param.co.in
dn: uid=testuser,dc=param,dc=co,dc=in
cn: test
sn: test
mail: testuser@param.co.in
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
uid: testuser

# search result
search: 2
result: 0 Success

# numResponses: 4
# numEntries: 3

Now I wanted to add OU with following ou.ldif file:

cn: ou=people,dc=param,dc=co,dc=in
objectClass: top
objectClass: organizationalUnit
ou: people

cn: ou=groups,dc=param,dc=co,dc=in
objectClass: top
objectClass: organizationalUnit
ou: groups

But it is giving no results i.e. no success neither error after adding this file using command:

$ ldapadd -x -W -D "cn=admin,dc=param,dc=co,dc=in" -f ou.ldif
Enter LDAP Password:
$

What wrong thing exactly am i doing here?


Solution

  • change 'cn' to 'dn' for distinguished name. 'cn' is common name which would just be 'people' or 'groups' (except OUs don't need a CN). so it would be:

    dn: ou=people,dc=param,dc=co,dc=in
    objectClass: top
    objectClass: organizationalUnit
    ou: people
    
    dn: ou=groups,dc=param,dc=co,dc=in
    objectClass: top
    objectClass: organizationalUnit
    ou: groups