int ret, i, j;
struct ldb_message *msg = ares->message;
struct extended_dn_out_private *p;
-
+ struct ldb_context *ldb;
ac = talloc_get_type(req->context, struct extended_search_context);
p = talloc_get_type(ldb_module_get_private(ac->module), struct extended_dn_out_private);
-
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
if (ac->inject) {
/* for each record returned post-process to add any derived
attributes that have been asked for */
- ret = inject_extended_dn_out(ares, ldb_module_get_ctx(ac->module),
+ ret = inject_extended_dn_out(ares, ldb,
ac->extended_type, ac->remove_guid,
ac->remove_sid);
if (ret != LDB_SUCCESS) {
ret = ldb_msg_add_steal_string(ares->message, "distinguishedName",
ldb_dn_get_extended_linearized(ares->message, ares->message->dn, ac->extended_type));
} else {
- ret = ldb_msg_add_string(ares->message, "distinguishedName",
- ldb_dn_get_linearized(ares->message->dn));
+ ret = ldb_msg_add_dn(ares->message,
+ "distinguishedName",
+ ares->message->dn);
}
if (ret != LDB_SUCCESS) {
- ldb_oom(ldb_module_get_ctx(ac->module));
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
}
* correct case */
msg->elements[i].name = talloc_strdup(msg->elements, attribute->lDAPDisplayName);
if (!msg->elements[i].name) {
- ldb_oom(ldb_module_get_ctx(ac->module));
+ ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR);
}
}
struct ldb_dn *dn;
struct dsdb_dn *dsdb_dn = NULL;
struct ldb_val *plain_dn = &msg->elements[i].values[j];
- dsdb_dn = dsdb_dn_parse(msg, ldb_module_get_ctx(ac->module), plain_dn, attribute->syntax->ldap_oid);
+ dsdb_dn = dsdb_dn_parse(msg, ldb, plain_dn, attribute->syntax->ldap_oid);
if (!dsdb_dn || !ldb_dn_validate(dsdb_dn->dn)) {
- ldb_asprintf_errstring(ldb_module_get_ctx(ac->module),
- "could not parse %.*s as a %s DN", (int)plain_dn->length, plain_dn->data,
+ ldb_asprintf_errstring(ldb,
+ "could not parse %.*s in %s on %s as a %s DN",
+ (int)plain_dn->length, plain_dn->data,
+ msg->elements[i].name, ldb_dn_get_linearized(msg->dn),
attribute->syntax->ldap_oid);
talloc_free(dsdb_dn);
return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_INVALID_DN_SYNTAX);
}
if (!dn_str) {
- ldb_oom(ldb_module_get_ctx(ac->module));
+ ldb_oom(ldb);
talloc_free(dsdb_dn);
return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR);
}
return ldb_module_send_entry(ac->req, msg, ares->controls);
}
+static int extended_callback_ldb(struct ldb_request *req, struct ldb_reply *ares)
+{
+ return extended_callback(req, ares, NULL);
+}
+
static int extended_callback_openldap(struct ldb_request *req, struct ldb_reply *ares)
{
return extended_callback(req, ares, handle_dereference_openldap);
struct ldb_request *down_req;
char **new_attrs;
const char * const *const_attrs;
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
int ret;
struct extended_dn_out_private *p = talloc_get_type(ldb_module_get_private(module), struct extended_dn_out_private);
if (!control && storage_format_control && storage_format_control->data) {
extended_ctrl = talloc_get_type(storage_format_control->data, struct ldb_extended_dn_control);
if (!extended_ctrl) {
- ldb_set_errstring(ldb_module_get_ctx(module), "extended_dn_out: extended_ctrl was of the wrong data type");
+ ldb_set_errstring(ldb, "extended_dn_out: extended_ctrl was of the wrong data type");
return LDB_ERR_PROTOCOL_ERROR;
}
}
ac = talloc_zero(req, struct extended_search_context);
if (ac == NULL) {
- ldb_oom(ldb_module_get_ctx(module));
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
ac->module = module;
- ac->schema = dsdb_get_schema(ldb_module_get_ctx(module));
+ ac->schema = dsdb_get_schema(ldb);
ac->req = req;
ac->inject = false;
ac->remove_guid = false;
if (ac->remove_guid || ac->remove_sid) {
new_attrs = copy_attrs(ac, req->op.search.attrs);
if (new_attrs == NULL) {
- ldb_oom(ldb_module_get_ctx(module));
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
}
ret = ldb_build_search_req_ex(&down_req,
- ldb_module_get_ctx(module), ac,
+ ldb, ac,
req->op.search.base,
req->op.search.scope,
req->op.search.tree,
static int extended_dn_out_ldb_search(struct ldb_module *module, struct ldb_request *req)
{
- return extended_dn_out_search(module, req, extended_callback_openldap);
+ return extended_dn_out_search(module, req, extended_callback_ldb);
}
static int extended_dn_out_openldap_search(struct ldb_module *module, struct ldb_request *req)
int ret;
struct extended_dn_out_private *p = talloc(module, struct extended_dn_out_private);
+ struct dsdb_extended_dn_store_format *dn_format;
ldb_module_set_private(module, p);
return LDB_ERR_OPERATIONS_ERROR;
}
+ dn_format = talloc(p, struct dsdb_extended_dn_store_format);
+ if (!dn_format) {
+ talloc_free(p);
+ ldb_oom(ldb_module_get_ctx(module));
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ dn_format->store_extended_dn_in_ldb = true;
+ ret = ldb_set_opaque(ldb_module_get_ctx(module), DSDB_EXTENDED_DN_STORE_FORMAT_OPAQUE_NAME, dn_format);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(p);
+ return ret;
+ }
+
p->dereference = false;
p->normalise = false;
{
int ret, i = 0;
struct extended_dn_out_private *p = talloc_zero(module, struct extended_dn_out_private);
+ struct dsdb_extended_dn_store_format *dn_format;
struct dsdb_openldap_dereference_control *dereference_control;
struct dsdb_attribute *cur;
-
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
struct dsdb_schema *schema;
ldb_module_set_private(module, p);
if (!p) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ dn_format = talloc(p, struct dsdb_extended_dn_store_format);
+ if (!dn_format) {
+ talloc_free(p);
ldb_oom(ldb_module_get_ctx(module));
return LDB_ERR_OPERATIONS_ERROR;
}
+ dn_format->store_extended_dn_in_ldb = false;
+
+ ret = ldb_set_opaque(ldb_module_get_ctx(module), DSDB_EXTENDED_DN_STORE_FORMAT_OPAQUE_NAME, dn_format);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(p);
+ return ret;
+ }
+
p->dereference = true;
/* At the moment, servers that need dereference also need the
ret = ldb_mod_register_control(module, LDB_CONTROL_EXTENDED_DN_OID);
if (ret != LDB_SUCCESS) {
- ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_ERROR,
+ ldb_debug(ldb, LDB_DEBUG_ERROR,
"extended_dn_out: Unable to register control with rootdse!\n");
return LDB_ERR_OPERATIONS_ERROR;
}
return ret;
}
- schema = dsdb_get_schema(ldb_module_get_ctx(module));
+ schema = dsdb_get_schema(ldb);
if (!schema) {
/* No schema on this DB (yet) */
return LDB_SUCCESS;
= talloc_zero(p, struct dsdb_openldap_dereference_control);
if (!p->dereference_control) {
- ldb_oom(ldb_module_get_ctx(module));
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
= talloc_realloc(p, dereference_control->dereference,
struct dsdb_openldap_dereference *, i + 2);
if (!dereference_control) {
- ldb_oom(ldb_module_get_ctx(module));
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
dereference_control->dereference[i] = talloc(dereference_control->dereference,
struct dsdb_openldap_dereference);
if (!dereference_control->dereference[i]) {
- ldb_oom(ldb_module_get_ctx(module));
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
dereference_control->dereference[i]->source_attribute = cur->lDAPDisplayName;