From 13ca999b3b4660e530ac0b91342c40ff8a3c7a31 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Thu, 10 Jun 2010 16:08:23 +0200 Subject: s4:samldb LDB module - don't create multiple "ac" module contexts on modify operations Since we do now run sequentially through all checks we don't need multiple "ac" contexts anymore. --- source4/dsdb/samdb/ldb_modules/samldb.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index 64a91c8fd2..a50739baa0 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -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); -- cgit