diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-11-04 20:27:43 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-11-04 20:35:44 +1100 |
commit | e606298631d9e4659e677041095511c1c353a4b5 (patch) | |
tree | c5d1a6014138acab3fb30c0705cd1a0ef661579e /source4/lib/ldb | |
parent | 1ab7bd1bfbfe5a27c91315d98c4e4949608d83e9 (diff) | |
download | samba-e606298631d9e4659e677041095511c1c353a4b5.tar.gz samba-e606298631d9e4659e677041095511c1c353a4b5.tar.bz2 samba-e606298631d9e4659e677041095511c1c353a4b5.zip |
s4-ldb: implement LDB_FLAG_INTERNAL_DISABLE_SINGLE_VALUE_CHECK
this disables the single value checking for one attribute. It is much
more specific than a general RELAX control, and also more efficient. I
think we should try to have more precise overrides like this, rather
than using RELAX as a general purpose override
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r-- | source4/lib/ldb/include/ldb_module.h | 3 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_tdb.c | 22 |
2 files changed, 12 insertions, 13 deletions
diff --git a/source4/lib/ldb/include/ldb_module.h b/source4/lib/ldb/include/ldb_module.h index f10e584f87..e88c887f20 100644 --- a/source4/lib/ldb/include/ldb_module.h +++ b/source4/lib/ldb/include/ldb_module.h @@ -43,6 +43,9 @@ struct ldb_module; */ #define LDB_FLAG_INTERNAL_DISABLE_VALIDATION 0x10 +/* disable any single value checking on this attribute */ +#define LDB_FLAG_INTERNAL_DISABLE_SINGLE_VALUE_CHECK 0x20 + /* these function pointers define the operations that a ldb module can intercept diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index b7432ab4d2..a498d541d3 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -301,7 +301,8 @@ static int ltdb_add_internal(struct ldb_module *module, el->name, ldb_dn_get_linearized(msg->dn)); return LDB_ERR_CONSTRAINT_VIOLATION; } - if (a && a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) { + if (a && (a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) && + !(el->flags & LDB_FLAG_INTERNAL_DISABLE_SINGLE_VALUE_CHECK)) { 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)); @@ -695,7 +696,8 @@ int ltdb_modify_internal(struct ldb_module *module, } } - if (a && a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) { + if (a && (a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) && + !(el->flags & LDB_FLAG_INTERNAL_DISABLE_SINGLE_VALUE_CHECK)) { 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(msg2->dn)); @@ -722,7 +724,8 @@ int ltdb_modify_internal(struct ldb_module *module, /* We cannot add another value on a existing one if the attribute is single-valued */ - if (a && a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) { + if (a && (a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) && + !(el->flags & LDB_FLAG_INTERNAL_DISABLE_SINGLE_VALUE_CHECK)) { ldb_asprintf_errstring(ldb, "SINGLE-VALUE attribute %s on %s specified more than once", el->name, ldb_dn_get_linearized(msg2->dn)); ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; @@ -788,16 +791,9 @@ int ltdb_modify_internal(struct ldb_module *module, case LDB_FLAG_MOD_REPLACE: - if (a && a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) { - /* the RELAX control overrides this - check for replace. This is needed as - DRS replication can produce multiple - values here for a single valued - attribute when the values are deleted - links - */ - if (el->num_values > 1 && - (!req || !ldb_request_get_control(req, LDB_CONTROL_RELAX_OID))) { + if (a && (a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) && + !(el->flags & LDB_FLAG_INTERNAL_DISABLE_SINGLE_VALUE_CHECK)) { + 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(msg2->dn)); ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; |