Fix include paths to new location of libutil.
[samba.git] / source4 / dsdb / samdb / ldb_modules / pdc_fsmo.c
index d78ba14ab46f14a4d3f8264a59fbde5174096d6f..198b6673582f9f2db9d7f7022be5b30ac5391657 100644 (file)
@@ -28,7 +28,7 @@
 #include "librpc/gen_ndr/ndr_misc.h"
 #include "librpc/gen_ndr/ndr_drsuapi.h"
 #include "librpc/gen_ndr/ndr_drsblobs.h"
-#include "lib/util/dlinklist.h"
+#include "../lib/util/dlinklist.h"
 
 static int pdc_fsmo_init(struct ldb_module *module)
 {
@@ -51,7 +51,7 @@ static int pdc_fsmo_init(struct ldb_module *module)
        pdc_dn = samdb_base_dn(module->ldb);
        if (!pdc_dn) {
                ldb_debug(module->ldb, LDB_DEBUG_WARNING,
-                         "pdc_fsmo_init: no domain dn present: (skip loading of domain details)");
+                         "pdc_fsmo_init: no domain dn present: (skip loading of domain details)\n");
                talloc_free(mem_ctx);
                return ldb_next_init(module);
        }
@@ -63,21 +63,24 @@ static int pdc_fsmo_init(struct ldb_module *module)
        }
        module->private_data = pdc_fsmo;
 
-       ret = ldb_search(module->ldb, pdc_dn,
-                        LDB_SCOPE_BASE,
-                        NULL, pdc_attrs,
-                        &pdc_res);
-       if (ret != LDB_SUCCESS) {
+       ret = ldb_search(module->ldb, mem_ctx, &pdc_res,
+                        pdc_dn, LDB_SCOPE_BASE,
+                        pdc_attrs, NULL);
+       if (ret == LDB_ERR_NO_SUCH_OBJECT) {
+               ldb_debug(module->ldb, LDB_DEBUG_WARNING,
+                         "pdc_fsmo_init: no domain object present: (skip loading of domain details)\n");
+               talloc_free(mem_ctx);
+               return ldb_next_init(module);
+       } else if (ret != LDB_SUCCESS) {
                ldb_debug_set(module->ldb, LDB_DEBUG_FATAL,
                              "pdc_fsmo_init: failed to search the domain object: %d:%s",
                              ret, ldb_strerror(ret));
                talloc_free(mem_ctx);
                return ret;
        }
-       talloc_steal(mem_ctx, pdc_res);
        if (pdc_res->count == 0) {
                ldb_debug(module->ldb, LDB_DEBUG_WARNING,
-                         "pdc_fsmo_init: no domain object present: (skip loading of domain details)");
+                         "pdc_fsmo_init: no domain object present: (skip loading of domain details)\n");
                talloc_free(mem_ctx);
                return ldb_next_init(module);
        } else if (pdc_res->count > 1) {
@@ -103,19 +106,14 @@ static int pdc_fsmo_init(struct ldb_module *module)
        talloc_steal(module, pdc_fsmo);
 
        ldb_debug(module->ldb, LDB_DEBUG_TRACE,
-                         "pdc_fsmo_init: we are master: %s",
+                         "pdc_fsmo_init: we are master: %s\n",
                          (pdc_fsmo->we_are_master?"yes":"no"));
 
        talloc_free(mem_ctx);
        return ldb_next_init(module);
 }
 
-static const struct ldb_module_ops pdc_fsmo_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_pdc_fsmo_module_ops = {
        .name           = "pdc_fsmo",
        .init_context   = pdc_fsmo_init
 };
-
-int pdc_fsmo_module_init(void)
-{
-       return ldb_register_module(&pdc_fsmo_ops);
-}