diff options
author | Andrew Tridgell <tridge@samba.org> | 2009-12-19 21:40:55 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-01-02 08:16:51 +1100 |
commit | 3c1259f10eb827de05198a8eaf79a4610d1d41e6 (patch) | |
tree | 188b255b800d2cd08d2c120517c01ee9a5eca45d /source4 | |
parent | 225bcfa4e6ad7efa7596e0324fd3faf1c195f820 (diff) | |
download | samba-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')
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/util.c | 29 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/util.h | 2 |
2 files changed, 31 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; +} diff --git a/source4/dsdb/samdb/ldb_modules/util.h b/source4/dsdb/samdb/ldb_modules/util.h index cc184eee8f..66579ab852 100644 --- a/source4/dsdb/samdb/ldb_modules/util.h +++ b/source4/dsdb/samdb/ldb_modules/util.h @@ -21,6 +21,8 @@ struct dsdb_schema; /* predeclare schema struct */ struct GUID; +struct dsdb_attribute; + #include "dsdb/samdb/ldb_modules/util_proto.h" #define DSDB_SEARCH_SEARCH_ALL_PARTITIONS 0x0001 |