s4-dsdb: allow modification of some deleted object if the show-deleted control is...
authorMatthieu Patou <mat@matws.net>
Fri, 11 May 2012 21:25:49 +0000 (14:25 -0700)
committerMatthieu Patou <mat@samba.org>
Sat, 19 May 2012 18:28:00 +0000 (20:28 +0200)
Autobuild-User: Matthieu Patou <mat@samba.org>
Autobuild-Date: Sat May 19 20:28:01 CEST 2012 on sn-devel-104

source4/dsdb/samdb/ldb_modules/descriptor.c

index 18245a0b79efb14ffb28c7671576e2073e8730e0..0a262885d8c4030ef2eba8a0286eceded8f10444 100644 (file)
@@ -581,7 +581,7 @@ static int descriptor_add(struct ldb_module *module, struct ldb_request *req)
 static int descriptor_modify(struct ldb_module *module, struct ldb_request *req)
 {
        struct ldb_context *ldb;
-       struct ldb_control *sd_recalculate_control, *sd_flags_control;
+       struct ldb_control *sd_recalculate_control, *sd_flags_control, *show_deleted_control;
        struct ldb_request *mod_req;
        struct ldb_message *msg;
        struct ldb_result *current_res, *parent_res;
@@ -591,7 +591,7 @@ static int descriptor_modify(struct ldb_module *module, struct ldb_request *req)
        struct ldb_dn *parent_dn, *dn;
        struct ldb_message_element *objectclass_element;
        int ret;
-       uint32_t instanceType, sd_flags = 0;
+       uint32_t instanceType, sd_flags = 0, flags;
        const struct dsdb_schema *schema;
        DATA_BLOB *sd;
        const struct dsdb_class *objectclass;
@@ -604,6 +604,8 @@ static int descriptor_modify(struct ldb_module *module, struct ldb_request *req)
        user_sd = ldb_msg_find_ldb_val(req->op.mod.message, "nTSecurityDescriptor");
        /* This control forces the recalculation of the SD also when
         * no modification is performed. */
+       show_deleted_control = ldb_request_get_control(req,
+                                            LDB_CONTROL_SHOW_DELETED_OID);
        sd_recalculate_control = ldb_request_get_control(req,
                                             LDB_CONTROL_RECALCULATE_SD_OID);
        if (!user_sd && !sd_recalculate_control) {
@@ -616,10 +618,13 @@ static int descriptor_modify(struct ldb_module *module, struct ldb_request *req)
        if (ldb_dn_is_special(dn)) {
                return ldb_next_request(module, req);
        }
-
+       flags = DSDB_FLAG_NEXT_MODULE;
+       if (show_deleted_control) {
+               flags |= DSDB_SEARCH_SHOW_DELETED;
+       }
        ret = dsdb_module_search_dn(module, req, &current_res, dn,
                                    current_attrs,
-                                   DSDB_FLAG_NEXT_MODULE,
+                                   flags,
                                    req);
        if (ret != LDB_SUCCESS) {
                ldb_debug(ldb, LDB_DEBUG_ERROR,"descriptor_modify: Could not find %s\n",