dsdb: Allow missing a mandatory attribute from a dbcheck fix
authorAndrew Bartlett <abartlet@samba.org>
Fri, 26 Aug 2016 03:54:35 +0000 (15:54 +1200)
committerStefan Metzmacher <metze@samba.org>
Mon, 29 Aug 2016 06:54:23 +0000 (08:54 +0200)
dbcheck of the rid pool (CN=RID Set) for another server will otherwise fail because
rIDNextRid is not replicated, and so it not present

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12178

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source4/dsdb/samdb/ldb_modules/objectclass_attrs.c

index f739c40ac83c6ce4944347daffb06c8d3579a131..c83c2e9fc4f2b4218c213e6bf104c69560af832b 100644 (file)
@@ -419,8 +419,15 @@ static int attr_handler2(struct oc_context *ac)
                }
        }
 
+       /*
+        * We skip this check under dbcheck to allow fixing of other
+        * attributes even if an attribute is missing.  This matters
+        * for CN=RID Set as the required attribute rIDNextRid is not
+        * replicated.
+        */
        if (found_must_contain[0] != NULL &&
-           ldb_msg_check_string_attribute(msg, "isDeleted", "TRUE") == 0) {
+           ldb_msg_check_string_attribute(msg, "isDeleted", "TRUE") == 0 &&
+           ldb_request_get_control(ac->req, DSDB_CONTROL_DBCHECK) == NULL) {
                ldb_asprintf_errstring(ldb, "objectclass_attrs: at least one mandatory attribute ('%s') on entry '%s' wasn't specified!",
                                       found_must_contain[0],
                                       ldb_dn_get_linearized(msg->dn));