#include <ldb_errors.h>
#include <ldb_module.h>
#include "dsdb/samdb/samdb.h"
-#include "util.h"
+#include "dsdb/samdb/ldb_modules/util.h"
/*
TODO: if relax is not set then we need to reject the fancy RMD_* and
int extended_type;
};
+static const char *wkattr[] = {
+ "wellKnownObjects",
+ "otherWellKnownObjects",
+ NULL
+};
/* An extra layer of indirection because LDB does not allow the original request to be altered */
static int extended_final_callback(struct ldb_request *req, struct ldb_reply *ares)
struct ldb_request *down_req;
struct ldb_message_element *el;
int ret;
- unsigned int i;
+ unsigned int i, j;
size_t wkn_len = 0;
char *valstr = NULL;
const char *found = NULL;
wkn_len = strlen(ac->wellknown_object);
- el = ldb_msg_find_element(ares->message, "wellKnownObjects");
- if (!el) {
- ac->basedn = NULL;
- break;
- }
-
- for (i=0; i < el->num_values; i++) {
- valstr = talloc_strndup(ac,
- (const char *)el->values[i].data,
- el->values[i].length);
- if (!valstr) {
- ldb_oom(ldb_module_get_ctx(ac->module));
- return ldb_module_done(ac->req, NULL, NULL,
- LDB_ERR_OPERATIONS_ERROR);
- }
+ for (j=0; wkattr[j]; j++) {
- if (strncasecmp(valstr, ac->wellknown_object, wkn_len) != 0) {
- talloc_free(valstr);
+ el = ldb_msg_find_element(ares->message, wkattr[j]);
+ if (!el) {
+ ac->basedn = NULL;
continue;
}
- found = &valstr[wkn_len];
- break;
+ for (i=0; i < el->num_values; i++) {
+ valstr = talloc_strndup(ac,
+ (const char *)el->values[i].data,
+ el->values[i].length);
+ if (!valstr) {
+ ldb_oom(ldb_module_get_ctx(ac->module));
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+
+ if (strncasecmp(valstr, ac->wellknown_object, wkn_len) != 0) {
+ talloc_free(valstr);
+ continue;
+ }
+
+ found = &valstr[wkn_len];
+ break;
+ }
+ if (found) {
+ break;
+ }
}
if (!found) {
enum ldb_scope scope;
struct ldb_dn *base_dn;
const char *expression;
+ uint32_t dsdb_flags;
if (tree->operation != LDB_OP_EQUALITY) {
return LDB_SUCCESS;
return LDB_SUCCESS;
}
+ dsdb_flags = DSDB_FLAG_NEXT_MODULE |
+ DSDB_SEARCH_SHOW_DELETED |
+ DSDB_SEARCH_SHOW_EXTENDED_DN;
+
if (guid_val) {
expression = talloc_asprintf(filter_ctx, "objectGUID=%s", ldb_binary_encode(filter_ctx, *guid_val));
scope = LDB_SCOPE_SUBTREE;
base_dn = NULL;
+ dsdb_flags |= DSDB_SEARCH_SEARCH_ALL_PARTITIONS;
} else if (sid_val) {
expression = talloc_asprintf(filter_ctx, "objectSID=%s", ldb_binary_encode(filter_ctx, *sid_val));
scope = LDB_SCOPE_SUBTREE;
base_dn = NULL;
+ dsdb_flags |= DSDB_SEARCH_SEARCH_ALL_PARTITIONS;
} else {
/* fallback to searching using the string DN as the base DN */
expression = "objectClass=*";
base_dn,
scope,
no_attrs,
- DSDB_FLAG_NEXT_MODULE |
- DSDB_SEARCH_SHOW_DELETED |
- DSDB_SEARCH_SHOW_EXTENDED_DN |
- DSDB_SEARCH_SEARCH_ALL_PARTITIONS,
+ dsdb_flags,
filter_ctx->req,
"%s", expression);
if (scope == LDB_SCOPE_BASE && ret == LDB_ERR_NO_SUCH_OBJECT) {
static const char *no_attr[] = {
NULL
};
- static const char *wkattr[] = {
- "wellKnownObjects",
- NULL
- };
bool all_partitions = false;
if (req->operation == LDB_SEARCH) {
*/
if (guid_val) {
all_partitions = true;
- base_dn = ldb_get_default_basedn(ldb_module_get_ctx(module));
+ base_dn = NULL;
base_dn_filter = talloc_asprintf(req, "(objectGUID=%s)",
ldb_binary_encode(req, *guid_val));
if (!base_dn_filter) {
} else if (sid_val) {
all_partitions = true;
- base_dn = ldb_get_default_basedn(ldb_module_get_ctx(module));
+ base_dn = NULL;
base_dn_filter = talloc_asprintf(req, "(objectSid=%s)",
ldb_binary_encode(req, *sid_val));
if (!base_dn_filter) {