]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/constraint.c
Merge remote-tracking branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_5
[openldap] / servers / slapd / overlays / constraint.c
index 897ad3c720c56f9bfd2315d1a2185ed94fd609cf..4e8b13dd6cd93a6539defe8816eecf6e4a9a2914 100644 (file)
@@ -771,7 +771,7 @@ constraint_add( Operation *op, SlapReply *rs )
        int rc;
        char *msg = NULL;
 
-       if (get_relax(op)) {
+       if (get_relax(op) || SLAPD_SYNC_IS_SYNCCONN( op->o_connid )) {
                return SLAP_CB_CONTINUE;
        }
 
@@ -855,6 +855,7 @@ constraint_check_count_violation( Modifications *m, Entry *target_entry, constra
                                ca = m->sml_numvals;
                                switch ( m->sml_op ) {
                                case LDAP_MOD_DELETE:
+                               case SLAP_MOD_SOFTDEL:
                                        if ( !ca || ca > ce ) {
                                                ce = 0;
                                        } else {
@@ -865,6 +866,7 @@ constraint_check_count_violation( Modifications *m, Entry *target_entry, constra
                                        break;
 
                                case LDAP_MOD_ADD:
+                               case SLAP_MOD_SOFTADD:
                                        ce += ca;
                                        break;
 
@@ -872,6 +874,11 @@ constraint_check_count_violation( Modifications *m, Entry *target_entry, constra
                                        ce = ca;
                                        break;
 
+#if 0
+                               /* TODO */
+                               case handle SLAP_MOD_ADD_IF_NOT_PRESENT:
+#endif
+
                                default:
                                        /* impossible! assert? */
                                        return 1;
@@ -903,7 +910,7 @@ constraint_update( Operation *op, SlapReply *rs )
        char *msg = NULL;
        int is_v;
 
-       if (get_relax(op)) {
+       if (get_relax(op) || SLAPD_SYNC_IS_SYNCCONN( op->o_connid )) {
                return SLAP_CB_CONTINUE;
        }
 
@@ -933,12 +940,12 @@ constraint_update( Operation *op, SlapReply *rs )
        rc = be_entry_get_rw( op, &op->o_req_ndn, NULL, NULL, 0, &target_entry );
        op->o_bd = be;
 
+       /* let the backend send the error */
+       if ( target_entry == NULL )
+               return SLAP_CB_CONTINUE;
+
        /* Do we need to count attributes? */
        for(cp = c; cp; cp = cp->ap_next) {
-               if (cp->restrict_lud && constraint_check_restrict(op, cp, target_entry) == 0) {
-                       continue;
-               }
-
                if (cp->count != 0) {
                        if (rc != 0 || target_entry == NULL) {
                                Debug(LDAP_DEBUG_TRACE, 
@@ -950,6 +957,10 @@ constraint_update( Operation *op, SlapReply *rs )
                                goto mod_violation;
                        }
 
+                       if (cp->restrict_lud && constraint_check_restrict(op, cp, target_entry) == 0) {
+                               continue;
+                       }
+
                        is_v = constraint_check_count_violation(m, target_entry, cp);
 
                        Debug(LDAP_DEBUG_TRACE,