s4:samldb LDB module - don't create multiple "ac" module contexts on modify operations
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Thu, 10 Jun 2010 14:08:23 +0000 (16:08 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Thu, 10 Jun 2010 14:22:08 +0000 (16:22 +0200)
Since we do now run sequentially through all checks we don't need multiple "ac"
contexts anymore.

source4/dsdb/samdb/ldb_modules/samldb.c

index 64a91c8fd293b7d609361fe576bccbfec7e93046..a50739baa03db4c0392ce0f0027eef9ccfdf01b0 100644 (file)
@@ -1395,6 +1395,7 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req)
 static int samldb_modify(struct ldb_module *module, struct ldb_request *req)
 {
        struct ldb_context *ldb;
+       struct samldb_ctx *ac;
        struct ldb_message *msg;
        struct ldb_message_element *el, *el2;
        int ret;
@@ -1421,6 +1422,11 @@ static int samldb_modify(struct ldb_module *module, struct ldb_request *req)
                }
        }
 
+       ac = samldb_ctx_init(module, req);
+       if (ac == NULL) {
+               return LDB_ERR_OPERATIONS_ERROR;
+       }
+
        /* TODO: do not modify original request, create a new one */
 
        el = ldb_msg_find_element(req->op.mod.message, "groupType");
@@ -1447,12 +1453,6 @@ static int samldb_modify(struct ldb_module *module, struct ldb_request *req)
 
        el = ldb_msg_find_element(req->op.mod.message, "primaryGroupID");
        if (el && (el->flags == LDB_FLAG_MOD_REPLACE) && el->num_values == 1) {
-               struct samldb_ctx *ac;
-
-               ac = samldb_ctx_init(module, req);
-               if (ac == NULL)
-                       return LDB_ERR_OPERATIONS_ERROR;
-
                req->op.mod.message = ac->msg = ldb_msg_copy_shallow(req,
                        req->op.mod.message);
 
@@ -1511,12 +1511,6 @@ static int samldb_modify(struct ldb_module *module, struct ldb_request *req)
 
        el = ldb_msg_find_element(req->op.mod.message, "member");
        if (el && el->flags & (LDB_FLAG_MOD_ADD|LDB_FLAG_MOD_REPLACE) && el->num_values == 1) {
-               struct samldb_ctx *ac;
-
-               ac = samldb_ctx_init(module, req);
-               if (ac == NULL)
-                       return LDB_ERR_OPERATIONS_ERROR;
-
                req->op.mod.message = ac->msg = ldb_msg_copy_shallow(req,
                        req->op.mod.message);