mirror of
https://github.com/samba-team/samba.git
synced 2025-02-04 17:47:26 +03:00
s4-dsdb: linked_attributes_modify no longer handles modifies
This functionality has moved into repl_meta_data
This commit is contained in:
parent
3b056061ff
commit
c071af337a
@ -408,188 +408,6 @@ static int la_mod_search_callback(struct ldb_request *req, struct ldb_reply *are
|
||||
}
|
||||
|
||||
|
||||
/* modify */
|
||||
static int linked_attributes_modify(struct ldb_module *module, struct ldb_request *req)
|
||||
{
|
||||
/* Look over list of modifications */
|
||||
/* Find if any are for linked attributes */
|
||||
/* Determine the effect of the modification */
|
||||
/* Apply the modify to the linked entry */
|
||||
|
||||
struct ldb_context *ldb;
|
||||
int i, j;
|
||||
struct la_context *ac;
|
||||
struct ldb_request *search_req;
|
||||
const char **attrs;
|
||||
|
||||
int ret;
|
||||
|
||||
ldb = ldb_module_get_ctx(module);
|
||||
|
||||
if (ldb_dn_is_special(req->op.mod.message->dn)) {
|
||||
/* do not manipulate our control entries */
|
||||
return ldb_next_request(module, req);
|
||||
}
|
||||
|
||||
ac = linked_attributes_init(module, req);
|
||||
if (!ac) {
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
|
||||
if (!ac->schema) {
|
||||
/* without schema, this doesn't make any sense */
|
||||
return ldb_next_request(module, req);
|
||||
}
|
||||
|
||||
ac->rc = talloc_zero(ac, struct replace_context);
|
||||
if (!ac->rc) {
|
||||
ldb_oom(ldb);
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
|
||||
for (i=0; i < req->op.mod.message->num_elements; i++) {
|
||||
bool store_el = false;
|
||||
const char *attr_name;
|
||||
const struct dsdb_attribute *target_attr;
|
||||
const struct ldb_message_element *el = &req->op.mod.message->elements[i];
|
||||
const struct dsdb_attribute *schema_attr
|
||||
= dsdb_attribute_by_lDAPDisplayName(ac->schema, el->name);
|
||||
if (!schema_attr) {
|
||||
ldb_asprintf_errstring(ldb,
|
||||
"attribute %s is not a valid attribute in schema", el->name);
|
||||
return LDB_ERR_OBJECT_CLASS_VIOLATION;
|
||||
}
|
||||
/* We have a valid attribute, now find out if it is linked */
|
||||
if (schema_attr->linkID == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((schema_attr->linkID & 1) == 1) {
|
||||
/* Odd is for the target. Illegal to modify */
|
||||
ldb_asprintf_errstring(ldb,
|
||||
"attribute %s must not be modified directly, it is a linked attribute", el->name);
|
||||
return LDB_ERR_UNWILLING_TO_PERFORM;
|
||||
}
|
||||
|
||||
/* Even link IDs are for the originating attribute */
|
||||
|
||||
/* Now find the target attribute */
|
||||
target_attr = dsdb_attribute_by_linkID(ac->schema, schema_attr->linkID + 1);
|
||||
if (!target_attr) {
|
||||
/*
|
||||
* windows 2003 has a broken schema where
|
||||
* the definition of msDS-IsDomainFor
|
||||
* is missing (which is supposed to be
|
||||
* the backlink of the msDS-HasDomainNCs
|
||||
* attribute
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
|
||||
attr_name = target_attr->lDAPDisplayName;
|
||||
|
||||
switch (el->flags & LDB_FLAG_MOD_MASK) {
|
||||
case LDB_FLAG_MOD_REPLACE:
|
||||
/* treat as just a normal add the delete part is handled by the callback */
|
||||
store_el = true;
|
||||
|
||||
/* break intentionally missing */
|
||||
|
||||
case LDB_FLAG_MOD_ADD:
|
||||
|
||||
/* For each value being added, we need to setup the adds */
|
||||
for (j = 0; j < el->num_values; j++) {
|
||||
ret = la_store_op(ac, LA_OP_ADD,
|
||||
&el->values[j],
|
||||
attr_name);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LDB_FLAG_MOD_DELETE:
|
||||
|
||||
if (el->num_values) {
|
||||
/* For each value being deleted, we need to setup the delete */
|
||||
for (j = 0; j < el->num_values; j++) {
|
||||
ret = la_store_op(ac, LA_OP_DEL,
|
||||
&el->values[j],
|
||||
attr_name);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Flag that there was a DELETE
|
||||
* without a value specified, so we
|
||||
* need to look for the old value */
|
||||
store_el = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (store_el) {
|
||||
struct ldb_message_element *search_el;
|
||||
|
||||
search_el = talloc_realloc(ac->rc, ac->rc->el,
|
||||
struct ldb_message_element,
|
||||
ac->rc->num_elements +1);
|
||||
if (!search_el) {
|
||||
ldb_oom(ldb);
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
ac->rc->el = search_el;
|
||||
|
||||
ac->rc->el[ac->rc->num_elements] = *el;
|
||||
ac->rc->num_elements++;
|
||||
}
|
||||
}
|
||||
|
||||
if (ac->ops || ac->rc->el) {
|
||||
/* both replace and delete without values are handled in the callback
|
||||
* after the search on the entry to be modified is performed */
|
||||
|
||||
attrs = talloc_array(ac->rc, const char *, ac->rc->num_elements + 1);
|
||||
if (!attrs) {
|
||||
ldb_oom(ldb);
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
for (i = 0; ac->rc && i < ac->rc->num_elements; i++) {
|
||||
attrs[i] = ac->rc->el[i].name;
|
||||
}
|
||||
attrs[i] = NULL;
|
||||
|
||||
/* The callback does all the hard work here */
|
||||
ret = ldb_build_search_req(&search_req, ldb, ac,
|
||||
req->op.mod.message->dn,
|
||||
LDB_SCOPE_BASE,
|
||||
"(objectClass=*)", attrs,
|
||||
NULL,
|
||||
ac, la_mod_search_callback,
|
||||
req);
|
||||
|
||||
/* We need to figure out our own extended DN, to fill in as the backlink target */
|
||||
if (ret == LDB_SUCCESS) {
|
||||
ret = ldb_request_add_control(search_req,
|
||||
LDB_CONTROL_EXTENDED_DN_OID,
|
||||
false, NULL);
|
||||
}
|
||||
if (ret == LDB_SUCCESS) {
|
||||
talloc_steal(search_req, attrs);
|
||||
|
||||
ret = ldb_next_request(module, search_req);
|
||||
}
|
||||
|
||||
} else {
|
||||
/* nothing to do for this module, proceed */
|
||||
talloc_free(ac);
|
||||
ret = ldb_next_request(module, req);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* delete */
|
||||
static int linked_attributes_del(struct ldb_module *module, struct ldb_request *req)
|
||||
@ -1250,7 +1068,6 @@ static int linked_attributes_del_transaction(struct ldb_module *module)
|
||||
_PUBLIC_ const struct ldb_module_ops ldb_linked_attributes_module_ops = {
|
||||
.name = "linked_attributes",
|
||||
.add = linked_attributes_add,
|
||||
.modify = linked_attributes_modify,
|
||||
.del = linked_attributes_del,
|
||||
.rename = linked_attributes_rename,
|
||||
.start_transaction = linked_attributes_start_transaction,
|
||||
|
Loading…
x
Reference in New Issue
Block a user