]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ndb/modify.cpp
add support for ADD_IF_NOT_PRESENT and SOFTDEL internal modification types (ITS#6561)
[openldap] / servers / slapd / back-ndb / modify.cpp
index 274bc093f230ecf86b3d0a39979ae3e73f9b5a0d..73bb9f755cd1a3b5975956eb991d418b6d2b7601 100644 (file)
@@ -300,6 +300,49 @@ int ndb_modify_internal(
                        }
                        break;
 
+               case SLAP_MOD_SOFTDEL:
+                       Debug(LDAP_DEBUG_ARGS,
+                               "ndb_modify_internal: softdel %s\n",
+                               mod->sm_desc->ad_cname.bv_val, 0, 0);
+                       mod->sm_op = LDAP_MOD_DELETE;
+
+                       rc = modify_delete_values( NA->e, mod, get_permissiveModify(op),
+                               text, textbuf, textlen );
+
+                       mod->sm_op = SLAP_MOD_SOFTDEL;
+
+                       if ( rc == LDAP_NO_SUCH_ATTRIBUTE) {
+                               rc = LDAP_SUCCESS;
+                       }
+
+                       if( rc != LDAP_SUCCESS ) {
+                               Debug(LDAP_DEBUG_ARGS, "ndb_modify_internal: %d %s\n",
+                                       rc, *text, 0);
+                       }
+                       break;
+
+               case SLAP_MOD_ADD_IF_NOT_PRESENT:
+                       Debug(LDAP_DEBUG_ARGS,
+                               "ndb_modify_internal: add_if_not_present %s\n",
+                               mod->sm_desc->ad_cname.bv_val, 0, 0);
+                       if ( attr_find( NA->e->e_attrs, mod->sm_desc ) ) {
+                               rc = LDAP_SUCCESS;
+                               break;
+                       }
+
+                       mod->sm_op = LDAP_MOD_ADD;
+
+                       rc = modify_add_values( NA->e, mod, get_permissiveModify(op),
+                               text, textbuf, textlen );
+
+                       mod->sm_op = SLAP_MOD_ADD_IF_NOT_PRESENT;
+
+                       if( rc != LDAP_SUCCESS ) {
+                               Debug(LDAP_DEBUG_ARGS, "ndb_modify_internal: %d %s\n",
+                                       rc, *text, 0);
+                       }
+                       break;
+
                default:
                        Debug(LDAP_DEBUG_ANY, "ndb_modify_internal: invalid op %d\n",
                                mod->sm_op, 0, 0);