mirror of
https://github.com/samba-team/samba.git
synced 2024-12-27 03:21:53 +03:00
s4-ldb: fixed an issue in rename/modify indexing
When we rename or modify a record, we need to update the indexes at the same time. It is important that we use the DN of the actual message that is stored in the database to do this, not the DN that was passed in by the user. If the two differ in case then the index records needs to use the 'real' record DN, as index handling is currently case sensitive.
This commit is contained in:
parent
2e46df492c
commit
3b96d08b29
@ -640,7 +640,7 @@ int ltdb_modify_internal(struct ldb_module *module,
|
||||
|
||||
if (ldb_attr_cmp(el->name, "distinguishedName") == 0) {
|
||||
ldb_asprintf_errstring(ldb, "it is not permitted to perform a modify on 'distinguishedName' (use rename instead): %s",
|
||||
ldb_dn_get_linearized(msg->dn));
|
||||
ldb_dn_get_linearized(msg2->dn));
|
||||
ret = LDB_ERR_CONSTRAINT_VIOLATION;
|
||||
goto done;
|
||||
}
|
||||
@ -649,7 +649,7 @@ int ltdb_modify_internal(struct ldb_module *module,
|
||||
case LDB_FLAG_MOD_ADD:
|
||||
if (el->num_values == 0) {
|
||||
ldb_asprintf_errstring(ldb, "attribute %s on %s specified, but with 0 values (illigal)",
|
||||
el->name, ldb_dn_get_linearized(msg->dn));
|
||||
el->name, ldb_dn_get_linearized(msg2->dn));
|
||||
ret = LDB_ERR_CONSTRAINT_VIOLATION;
|
||||
goto done;
|
||||
}
|
||||
@ -657,7 +657,7 @@ int ltdb_modify_internal(struct ldb_module *module,
|
||||
if (a && a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) {
|
||||
if (el->num_values > 1) {
|
||||
ldb_asprintf_errstring(ldb, "SINGLE-VALUE attribute %s on %s specified more than once",
|
||||
el->name, ldb_dn_get_linearized(msg->dn));
|
||||
el->name, ldb_dn_get_linearized(msg2->dn));
|
||||
ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
|
||||
goto done;
|
||||
}
|
||||
@ -670,7 +670,7 @@ int ltdb_modify_internal(struct ldb_module *module,
|
||||
ret = LDB_ERR_OTHER;
|
||||
goto done;
|
||||
}
|
||||
ret = ltdb_index_add_element(module, msg->dn, el);
|
||||
ret = ltdb_index_add_element(module, msg2->dn, el);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
@ -679,7 +679,7 @@ int ltdb_modify_internal(struct ldb_module *module,
|
||||
if the attribute is single-valued */
|
||||
if (a && a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) {
|
||||
ldb_asprintf_errstring(ldb, "SINGLE-VALUE attribute %s on %s specified more than once",
|
||||
el->name, ldb_dn_get_linearized(msg->dn));
|
||||
el->name, ldb_dn_get_linearized(msg2->dn));
|
||||
ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
|
||||
goto done;
|
||||
}
|
||||
@ -720,7 +720,7 @@ int ltdb_modify_internal(struct ldb_module *module,
|
||||
el2->values = vals;
|
||||
el2->num_values += el->num_values;
|
||||
|
||||
ret = ltdb_index_add_element(module, msg->dn, el);
|
||||
ret = ltdb_index_add_element(module, msg2->dn, el);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
@ -732,7 +732,7 @@ int ltdb_modify_internal(struct ldb_module *module,
|
||||
if (a && a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) {
|
||||
if (el->num_values > 1) {
|
||||
ldb_asprintf_errstring(ldb, "SINGLE-VALUE attribute %s on %s specified more than once",
|
||||
el->name, ldb_dn_get_linearized(msg->dn));
|
||||
el->name, ldb_dn_get_linearized(msg2->dn));
|
||||
ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
|
||||
goto done;
|
||||
}
|
||||
@ -768,7 +768,7 @@ int ltdb_modify_internal(struct ldb_module *module,
|
||||
goto done;
|
||||
}
|
||||
|
||||
ret = ltdb_index_add_element(module, msg->dn, el);
|
||||
ret = ltdb_index_add_element(module, msg2->dn, el);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
@ -776,7 +776,7 @@ int ltdb_modify_internal(struct ldb_module *module,
|
||||
break;
|
||||
|
||||
case LDB_FLAG_MOD_DELETE:
|
||||
dn = ldb_dn_get_linearized(msg->dn);
|
||||
dn = ldb_dn_get_linearized(msg2->dn);
|
||||
if (dn == NULL) {
|
||||
ret = LDB_ERR_OTHER;
|
||||
goto done;
|
||||
@ -821,7 +821,7 @@ int ltdb_modify_internal(struct ldb_module *module,
|
||||
goto done;
|
||||
}
|
||||
|
||||
ret = ltdb_modified(module, msg->dn);
|
||||
ret = ltdb_modified(module, msg2->dn);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
@ -885,20 +885,20 @@ static int ltdb_rename(struct ltdb_context *ctx)
|
||||
return ret;
|
||||
}
|
||||
|
||||
msg->dn = ldb_dn_copy(msg, req->op.rename.newdn);
|
||||
if (msg->dn == NULL) {
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
|
||||
/* Always delete first then add, to avoid conflicts with
|
||||
* unique indexes. We rely on the transaction to make this
|
||||
* atomic
|
||||
*/
|
||||
ret = ltdb_delete_internal(module, req->op.rename.olddn);
|
||||
ret = ltdb_delete_internal(module, msg->dn);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
msg->dn = ldb_dn_copy(msg, req->op.rename.newdn);
|
||||
if (msg->dn == NULL) {
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
|
||||
ret = ltdb_add_internal(module, msg);
|
||||
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user