#include "ldb/include/ldb_errors.h"
#include "ldb/include/ldb_module.h"
+/*
+ TODO: if relax is not set then we need to reject the fancy RMD_* and
+ DELETED extended DN codes
+ */
+
/* search */
struct extended_search_context {
struct ldb_module *module;
if (!ac->basedn) {
const char *str = talloc_asprintf(req, "Base-DN '%s' not found",
- ldb_dn_get_linearized(ac->req->op.search.base));
+ ldb_dn_get_extended_linearized(req, ac->req->op.search.base, 1));
ldb_set_errstring(ldb_module_get_ctx(ac->module), str);
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_NO_SUCH_OBJECT);
"wellKnownObjects",
NULL
};
+ bool all_partitions = false;
if (!ldb_dn_has_extended(dn)) {
/* Move along there isn't anything to see here */
wkguid_val = ldb_dn_get_extended_component(dn, "WKGUID");
if (sid_val) {
- /* TODO: do a search over all partitions */
+ all_partitions = true;
base_dn = ldb_get_default_basedn(ldb_module_get_ctx(module));
base_dn_filter = talloc_asprintf(req, "(objectSid=%s)",
ldb_binary_encode(req, *sid_val));
if (!base_dn_filter) {
- ldb_oom(ldb_module_get_ctx(module));
- return LDB_ERR_OPERATIONS_ERROR;
+ return ldb_oom(ldb_module_get_ctx(module));
}
base_dn_scope = LDB_SCOPE_SUBTREE;
base_dn_attrs = no_attr;
} else if (guid_val) {
- /* TODO: do a search over all partitions */
+ all_partitions = true;
base_dn = ldb_get_default_basedn(ldb_module_get_ctx(module));
base_dn_filter = talloc_asprintf(req, "(objectGUID=%s)",
ldb_binary_encode(req, *guid_val));
if (!base_dn_filter) {
- ldb_oom(ldb_module_get_ctx(module));
- return LDB_ERR_OPERATIONS_ERROR;
+ return ldb_oom(ldb_module_get_ctx(module));
}
base_dn_scope = LDB_SCOPE_SUBTREE;
base_dn_attrs = no_attr;
wellknown_object = talloc_asprintf(req, "B:32:%s:", wkguid_dup);
if (!wellknown_object) {
- ldb_oom(ldb_module_get_ctx(module));
- return LDB_ERR_OPERATIONS_ERROR;
+ return ldb_oom(ldb_module_get_ctx(module));
}
tail_str = p;
base_dn = ldb_dn_new(req, ldb_module_get_ctx(module), tail_str);
talloc_free(wkguid_dup);
if (!base_dn) {
- ldb_oom(ldb_module_get_ctx(module));
- return LDB_ERR_OPERATIONS_ERROR;
+ return ldb_oom(ldb_module_get_ctx(module));
}
base_dn_filter = talloc_strdup(req, "(objectClass=*)");
if (!base_dn_filter) {
- ldb_oom(ldb_module_get_ctx(module));
- return LDB_ERR_OPERATIONS_ERROR;
+ return ldb_oom(ldb_module_get_ctx(module));
}
base_dn_scope = LDB_SCOPE_BASE;
base_dn_attrs = wkattr;
ac = talloc_zero(req, struct extended_search_context);
if (ac == NULL) {
- ldb_oom(ldb_module_get_ctx(module));
- return LDB_ERR_OPERATIONS_ERROR;
+ return ldb_oom(ldb_module_get_ctx(module));
}
ac->module = module;
ac, extended_base_callback,
req);
if (ret != LDB_SUCCESS) {
- return LDB_ERR_OPERATIONS_ERROR;
+ return ldb_operr(ldb_module_get_ctx(module));
+ }
+
+ if (all_partitions) {
+ struct ldb_search_options_control *control;
+ control = talloc(down_req, struct ldb_search_options_control);
+ control->search_options = 2;
+ ret = ldb_request_add_control(down_req,
+ LDB_CONTROL_SEARCH_OPTIONS_OID,
+ true, control);
+ if (ret != LDB_SUCCESS) {
+ ldb_oom(ldb_module_get_ctx(module));
+ return ret;
+ }
}
/* perform the search */