summaryrefslogtreecommitdiff
path: root/source4/dsdb/samdb/ldb_modules/util.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-12-19 21:40:55 +1100
committerAndrew Tridgell <tridge@samba.org>2010-01-02 08:16:51 +1100
commit3c1259f10eb827de05198a8eaf79a4610d1d41e6 (patch)
tree188b255b800d2cd08d2c120517c01ee9a5eca45d /source4/dsdb/samdb/ldb_modules/util.c
parent225bcfa4e6ad7efa7596e0324fd3faf1c195f820 (diff)
downloadsamba-3c1259f10eb827de05198a8eaf79a4610d1d41e6.tar.gz
samba-3c1259f10eb827de05198a8eaf79a4610d1d41e6.tar.bz2
samba-3c1259f10eb827de05198a8eaf79a4610d1d41e6.zip
s4-dsdb: added dsdb_check_single_valued_link()
This is used in conjunction with the RELAX control, to check for violations of single value rules for linked attributes
Diffstat (limited to 'source4/dsdb/samdb/ldb_modules/util.c')
-rw-r--r--source4/dsdb/samdb/ldb_modules/util.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/util.c b/source4/dsdb/samdb/ldb_modules/util.c
index b0ccd0341c..fa451f4bcf 100644
--- a/source4/dsdb/samdb/ldb_modules/util.c
+++ b/source4/dsdb/samdb/ldb_modules/util.c
@@ -371,3 +371,32 @@ const struct dsdb_class * get_last_structural_class(const struct dsdb_schema *sc
return last_class;
}
+
+/*
+ check if a single valued link has multiple non-deleted values
+
+ This is needed when we will be using the RELAX control to stop
+ ldb_tdb from checking single valued links
+ */
+int dsdb_check_single_valued_link(const struct dsdb_attribute *attr,
+ const struct ldb_message_element *el)
+{
+ bool found_active = false;
+ int i;
+
+ if (!(attr->ldb_schema_attribute->flags & LDB_ATTR_FLAG_SINGLE_VALUE) ||
+ el->num_values < 2) {
+ return LDB_SUCCESS;
+ }
+
+ for (i=0; i<el->num_values; i++) {
+ if (!dsdb_dn_is_deleted_val(&el->values[i])) {
+ if (found_active) {
+ return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
+ }
+ found_active = true;
+ }
+ }
+
+ return LDB_SUCCESS;
+}