- ret = dsdb_search(s->samdb, do_dn, &res, do_dn, LDB_SCOPE_ONELEVEL, attrs,
- DSDB_SEARCH_SHOW_RECYCLED, NULL);
+
+ if (!do_fs && ldb_dn_compare(ldb_get_config_basedn(s->samdb), part->dn)) {
+ ret = dsdb_search(s->samdb, do_dn, &res, do_dn, LDB_SCOPE_ONELEVEL, attrs,
+ DSDB_SEARCH_SHOW_RECYCLED, NULL);
+ } else {
+ if (do_fs) {
+ DEBUG(1, ("Doing a full scan on %s and looking for deleted object\n",
+ ldb_dn_get_linearized(part->dn)));
+ }
+ ret = dsdb_search(s->samdb, part->dn, &res, part->dn, LDB_SCOPE_SUBTREE, attrs,
+ DSDB_SEARCH_SHOW_RECYCLED, "(isDeleted=TRUE)");
+ }