dsdb: Add a dummy module to replace show_deleted
authorAndrew Bartlett <abartlet@samba.org>
Wed, 28 Jun 2017 00:22:05 +0000 (12:22 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 30 Jun 2017 00:12:22 +0000 (02:12 +0200)
This helps when we improve show_deleted in a way that the fake database in samba3sam can not cover

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
python/samba/tests/samba3sam.py
source4/dsdb/samdb/ldb_modules/samba3sam.c

index 3a189e0992843cecfd3224788d9a9d50be90bed8..929523b768dd0ac044c11b00dd7ed6bf01fad719 100644 (file)
@@ -53,7 +53,7 @@ class MapBaseTestCase(TestCaseInTempDir):
                  "@TO": "sambaDomainName=TESTS," + s3.basedn})
 
         ldb.add({"dn": "@MODULES",
-                 "@LIST": "rootdse,paged_results,server_sort,asq,samldb,password_hash,operational,objectguid,rdn_name,samba3sam,samba3sid,show_deleted,dsdb_flags_ignore,partition"})
+                 "@LIST": "rootdse,paged_results,server_sort,asq,samldb,password_hash,operational,objectguid,rdn_name,samba3sam,samba3sid,show_deleted_ignore,dsdb_flags_ignore,partition"})
 
         ldb.add({"dn": "@PARTITION",
             "partition": ["%s" % (s4.basedn_casefold),
index e9830c904560fa33a15fc7bc1dbf54dba92dafa4..31c01a75a85bde1f7dd5a337e28e9ff9dadc3e08 100644 (file)
@@ -934,8 +934,44 @@ static const struct ldb_module_ops ldb_samba3sam_module_ops = {
        .init_context      = samba3sam_init,
 };
 
+
+/* A dummy module to help the samba3sam tests */
+static int show_deleted_ignore_search(struct ldb_module *module, struct ldb_request *req)
+{
+       struct ldb_control *show_del, *show_rec;
+
+       /* check if there's a show deleted control */
+       show_del = ldb_request_get_control(req, LDB_CONTROL_SHOW_DELETED_OID);
+       /* check if there's a show recycled control */
+       show_rec = ldb_request_get_control(req, LDB_CONTROL_SHOW_RECYCLED_OID);
+
+       /* mark the controls as done */
+       if (show_del != NULL) {
+               show_del->critical = 0;
+       }
+       if (show_rec != NULL) {
+               show_rec->critical = 0;
+       }
+
+       /* perform the search */
+       return ldb_next_request(module, req);
+}
+
+static const struct ldb_module_ops ldb_show_deleted_module_ops = {
+       .name              = "show_deleted_ignore",
+       .search            = show_deleted_ignore_search
+};
+
 int ldb_samba3sam_module_init(const char *version)
 {
+       int ret;
+       
        LDB_MODULE_CHECK_VERSION(version);
+       ret = ldb_register_module(&ldb_show_deleted_module_ops);
+       if (ret != LDB_SUCCESS) {
+               return ret;
+       }
+
        return ldb_register_module(&ldb_samba3sam_module_ops);
 }
+