s4-dsdb: replaced the calls to ldb_search() in dsdb modules with dsdb_module_search()
authorAndrew Tridgell <tridge@samba.org>
Mon, 17 Jan 2011 02:39:46 +0000 (13:39 +1100)
committerAndrew Tridgell <tridge@samba.org>
Mon, 17 Jan 2011 04:23:04 +0000 (05:23 +0100)
this ensures we follow the module stack, and set the parent on child
requests

source4/dsdb/samdb/ldb_modules/rootdse.c
source4/dsdb/samdb/ldb_modules/samldb.c
source4/dsdb/samdb/ldb_modules/update_keytab.c
source4/dsdb/samdb/ldb_modules/wscript_build

index 157a8c0ae5f21b13e64e88ab240a2557d3f31ef4..007af57d540458220e3292145ccadd4c67f5f850 100644 (file)
@@ -802,9 +802,9 @@ static int rootdse_init(struct ldb_module *module)
 
           Then stuff these values into an opaque
        */
-       ret = ldb_search(ldb, mem_ctx, &res,
-                        ldb_get_default_basedn(ldb),
-                        LDB_SCOPE_BASE, attrs, NULL);
+       ret = dsdb_module_search(module, mem_ctx, &res,
+                                ldb_get_default_basedn(ldb),
+                                LDB_SCOPE_BASE, attrs, DSDB_FLAG_NEXT_MODULE, NULL, NULL);
        if (ret == LDB_SUCCESS && res->count == 1) {
                int domain_behaviour_version
                        = ldb_msg_find_attr_as_int(res->msgs[0],
@@ -824,9 +824,9 @@ static int rootdse_init(struct ldb_module *module)
                }
        }
 
-       ret = ldb_search(ldb, mem_ctx, &res,
-                        samdb_partitions_dn(ldb, mem_ctx),
-                        LDB_SCOPE_BASE, attrs, NULL);
+       ret = dsdb_module_search(module, mem_ctx, &res,
+                                samdb_partitions_dn(ldb, mem_ctx),
+                                LDB_SCOPE_BASE, attrs, DSDB_FLAG_NEXT_MODULE, NULL, NULL);
        if (ret == LDB_SUCCESS && res->count == 1) {
                int forest_behaviour_version
                        = ldb_msg_find_attr_as_int(res->msgs[0],
@@ -846,16 +846,16 @@ static int rootdse_init(struct ldb_module *module)
                }
        }
 
-       ret = ldb_search(ldb, mem_ctx, &res,
-                        ldb_dn_new(mem_ctx, ldb, ""),
-                        LDB_SCOPE_BASE, ds_attrs, NULL);
+       ret = dsdb_module_search(module, mem_ctx, &res,
+                                ldb_dn_new(mem_ctx, ldb, ""),
+                                LDB_SCOPE_BASE, ds_attrs, DSDB_FLAG_NEXT_MODULE, NULL, NULL);
        if (ret == LDB_SUCCESS && res->count == 1) {
                struct ldb_dn *ds_dn
                        = ldb_msg_find_attr_as_dn(ldb, mem_ctx, res->msgs[0],
                                                  "dsServiceName");
                if (ds_dn) {
-                       ret = ldb_search(ldb, mem_ctx, &res, ds_dn,
-                                        LDB_SCOPE_BASE, attrs, NULL);
+                       ret = dsdb_module_search(module, mem_ctx, &res, ds_dn,
+                                                LDB_SCOPE_BASE, attrs, DSDB_FLAG_NEXT_MODULE, NULL, NULL);
                        if (ret == LDB_SUCCESS && res->count == 1) {
                                int domain_controller_behaviour_version
                                        = ldb_msg_find_attr_as_int(res->msgs[0],
index 53c45e62bc00feceb8ad17f2434be00b9ac54cab..ee0d66cc049b5a5eb92a3e8afe0c573c8b8e2c33 100644 (file)
@@ -1075,8 +1075,8 @@ static int samldb_prim_group_change(struct samldb_ctx *ac)
 
        /* Fetch informations from the existing object */
 
-       ret = ldb_search(ldb, ac, &res, ac->msg->dn, LDB_SCOPE_BASE, attrs,
-                        NULL);
+       ret = dsdb_module_search(ac->module, ac, &res, ac->msg->dn, LDB_SCOPE_BASE, attrs,
+                                DSDB_FLAG_NEXT_MODULE, ac->req, NULL);
        if (ret != LDB_SUCCESS) {
                return ret;
        }
@@ -1432,8 +1432,9 @@ static int samldb_sam_accountname_check(struct samldb_ctx *ac)
 
        /* Make sure that a "sAMAccountName" is only used once */
 
-       ret = ldb_search(ldb, ac, &res, NULL, LDB_SCOPE_SUBTREE, no_attrs,
-                        "(sAMAccountName=%s)", enc_str);
+       ret = dsdb_module_search(ac->module, ac, &res, NULL, LDB_SCOPE_SUBTREE, no_attrs,
+                                DSDB_FLAG_NEXT_MODULE, ac->req,
+                                "(sAMAccountName=%s)", enc_str);
        if (ret != LDB_SUCCESS) {
                return ret;
        }
@@ -1467,8 +1468,8 @@ static int samldb_member_check(struct samldb_ctx *ac)
 
        /* Fetch informations from the existing object */
 
-       ret = ldb_search(ldb, ac, &res, ac->msg->dn, LDB_SCOPE_BASE, attrs,
-                        NULL);
+       ret = dsdb_module_search(ac->module, ac, &res, ac->msg->dn, LDB_SCOPE_BASE, attrs,
+                                DSDB_FLAG_NEXT_MODULE, ac->req, NULL);
        if (ret != LDB_SUCCESS) {
                return ret;
        }
@@ -1582,8 +1583,8 @@ static int samldb_description_check(struct samldb_ctx *ac)
 
        /* Fetch informations from the existing object */
 
-       ret = ldb_search(ldb, ac, &res, ac->msg->dn, LDB_SCOPE_BASE, attrs,
-                        NULL);
+       ret = dsdb_module_search(ac->module, ac, &res, ac->msg->dn, LDB_SCOPE_BASE, attrs,
+                                DSDB_FLAG_NEXT_MODULE, ac->req, NULL);
        if (ret != LDB_SUCCESS) {
                return ret;
        }
@@ -1782,8 +1783,8 @@ static int samldb_service_principal_names_change(struct samldb_ctx *ac)
        }
 
        /* Fetch the "servicePrincipalName"s if any */
-       ret = ldb_search(ldb, ac, &res, ac->msg->dn, LDB_SCOPE_BASE, attrs,
-                        NULL);
+       ret = dsdb_module_search(ac->module, ac, &res, ac->msg->dn, LDB_SCOPE_BASE, attrs,
+                                DSDB_FLAG_NEXT_MODULE, ac->req, NULL);
        if (ret != LDB_SUCCESS) {
                return ret;
        }
index 6a9245f89e04ffa7e0654d8664c07f1d52dbb559..81d672b5ec3e9610b50cfdfad914a816d7f79191 100644 (file)
@@ -34,6 +34,7 @@
 #include "auth/credentials/credentials_krb5.h"
 #include "system/kerberos.h"
 #include "auth/kerberos/kerberos.h"
+#include "util.h"
 
 struct dn_list {
        struct ldb_message *msg;
@@ -78,7 +79,9 @@ static struct update_kt_ctx *update_kt_ctx_init(struct ldb_module *module,
  * Just hope we are lucky and nothing breaks (using the tdb backend masks a lot
  * of async issues). -SSS
  */
-static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool do_delete) {
+static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool do_delete,
+                       struct ldb_request *parent)
+{
        struct ldb_context *ldb = ldb_module_get_ctx(module);
        struct update_kt_private *data = talloc_get_type(ldb_module_get_private(module), struct update_kt_private);
        struct dn_list *item;
@@ -92,8 +95,10 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool do_de
                return ldb_oom(ldb);
        }
 
-       ret = ldb_search(ldb, data, &res,
-                        dn, LDB_SCOPE_BASE, NULL, "%s", filter);
+       ret = dsdb_module_search(module, data, &res,
+                                dn, LDB_SCOPE_BASE, NULL,
+                                DSDB_FLAG_NEXT_MODULE, parent,
+                                "%s", filter);
        talloc_free(filter);
        if (ret != LDB_SUCCESS) {
                return ret;
@@ -214,7 +219,7 @@ static int ukt_search_modified_callback(struct ldb_request *req,
 
                if (ac->found) {
                        /* do the dirty sync job here :/ */
-                       ret = add_modified(ac->module, ac->dn, ac->do_delete);
+                       ret = add_modified(ac->module, ac->dn, ac->do_delete, ac->req);
                }
 
                if (ac->do_delete) {
index 4cf1cfe19ab967eeac64a3f56b4e6e4f81a5b99f..0b269007e46783be76ab0dcfef40b2d25d7ff25d 100644 (file)
@@ -240,7 +240,7 @@ bld.SAMBA_MODULE('ldb_update_keytab',
        init_function='ldb_update_keytab_module_init',
        module_init_name='ldb_init_module',
        internal_module=False,
-       deps='talloc events credentials ldb com_err KERBEROS_UTIL'
+       deps='talloc events credentials ldb com_err KERBEROS_UTIL DSDB_MODULE_HELPERS'
        )