s4-dsdb: failing to find the object is not an error in dsdb_loadreps()
authorAndrew Tridgell <tridge@samba.org>
Tue, 20 Sep 2011 22:51:20 +0000 (08:51 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 22 Sep 2011 00:00:48 +0000 (10:00 +1000)
we may not have replicated the partition yet, so this should be
considered the same as having no repsFrom/repsTo

source4/dsdb/common/util.c

index 3276ec801931ad55d01a99d46dd7f405debc35b7..f5443ea59d2d8b6657caa4a376dc454d3ac50133 100644 (file)
@@ -2667,13 +2667,18 @@ WERROR dsdb_loadreps(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, struct ld
        TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
        unsigned int i;
        struct ldb_message_element *el;
+       int ret;
 
        *r = NULL;
        *count = 0;
 
-       if (ldb_search(sam_ctx, tmp_ctx, &res, dn, LDB_SCOPE_BASE, attrs, NULL) != LDB_SUCCESS ||
-           res->count < 1) {
-               DEBUG(0,("dsdb_loadreps: failed to read partition object\n"));
+       ret = dsdb_search_dn(sam_ctx, tmp_ctx, &res, dn, attrs, 0);
+       if (ret == LDB_ERR_NO_SUCH_OBJECT) {
+               /* partition hasn't been replicated yet */
+               return WERR_OK;
+       }
+       if (ret != LDB_SUCCESS) {
+               DEBUG(0,("dsdb_loadreps: failed to read partition object: %s\n", ldb_errstring(sam_ctx)));
                talloc_free(tmp_ctx);
                return WERR_DS_DRA_INTERNAL_ERROR;
        }