Ldap – Using ldapModify to delete objectClass in LDAP entry

ldap

I have a need to delete three different objectClasses from a bunch of LDAP entries. Here's my ldif file:

dn: uid=user,ou=People,dc=example,dc=net
changetype: modify
delete: objectClass
objectClass: top
-
delete: objectClass
objectClass: organizationalPerson
-
delete: objectClass
objectClass: person

When I run the ldapmodify command, I get the following output:

ldap_initialize( ldap://server.net )
delete objectClass:
        top
delete objectClass:
        organizationalPerson
delete objectClass:
        person
modifying entry "uid=user,ou=People,dc=example,dc=net"
modify complete

However, when I perform an ldapsearch on that user, all the objectClasses are still there. Clearly, it matches the object class name otherwise it would complain.

Best Answer

I suspect your entries have attributes that require the objectClasses your are trying to remove. You need to remove the attributes that depend on the objectClasses before you remove the object class.

I don't know which LDAP server you are using, but I have had to remove entries to remove object clasees. This was done by extracting the record, removing the original record, and adding the record with a modified list of object classes. The add fails if you keep attributes not supported by the new object class hierarchy.