/* TODO: This is O(n^2) - replace with more efficient check */
for (j=0; j<el->num_values; j++) {
- if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) {
+ struct ldb_val *matched_val = NULL;
+
+ ret = ldb_msg_find_val_schema(ldb, a, el,
+ &el->values[j],
+ &matched_val);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+
+ if (matched_val == NULL) {
+ /*
+ * Something went completely wrong
+ * This must find the value itself!!!
+ */
+ return ldb_operr(ldb);
+ }
+
+ if (matched_val != &el->values[j]) {
ldb_asprintf_errstring(ldb,
"attribute '%s': value #%u on '%s' provided more than once",
el->name, j, ldb_dn_get_linearized(msg->dn));
for (i=0;i<el->num_values;i++) {
bool matched;
- if (a->syntax->operator_fn) {
- ret = a->syntax->operator_fn(ldb, LDB_OP_EQUALITY, a,
- &el->values[i], val, &matched);
- if (ret != LDB_SUCCESS) return ret;
- } else {
- matched = (a->syntax->comparison_fn(ldb, ldb,
- &el->values[i], val) == 0);
+ ret = ldb_val_equal_schema(ldb, a, &el->values[i], val, &matched);
+ if (ret != LDB_SUCCESS) {
+ return ret;
}
if (matched) {
if (el->num_values == 1) {
valued attributes or aren't provided twice */
/* TODO: This is O(n^2) - replace with more efficient check */
for (j = 0; j < el->num_values; j++) {
- if (ldb_msg_find_val(el2, &el->values[j]) != NULL) {
+ struct ldb_val *matched_val = NULL;
+
+ ret = ldb_msg_find_val_schema(ldb, a, el2,
+ &el->values[j],
+ &matched_val);
+ if (ret != LDB_SUCCESS) {
+ goto done;
+ }
+
+ if (matched_val != NULL) {
if (control_permissive) {
/* remove this one as if it was never added */
el->num_values--;
ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
goto done;
}
- if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) {
+
+ matched_val = NULL;
+ ret = ldb_msg_find_val_schema(ldb, a, el,
+ &el->values[j],
+ &matched_val);
+ if (ret != LDB_SUCCESS) {
+ goto done;
+ }
+
+ if (matched_val == NULL) {
+ /*
+ * Something went completely wrong
+ * This must find the value itself!!!
+ */
+ ret = ldb_operr(ldb);
+ goto done;
+ }
+
+ if (matched_val != &el->values[j]) {
ldb_asprintf_errstring(ldb,
"attribute '%s': value #%u on '%s' provided more than once",
el->name, j, ldb_dn_get_linearized(msg2->dn));
/* TODO: This is O(n^2) - replace with more efficient check */
for (j=0; j<el->num_values; j++) {
- if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) {
+ struct ldb_val *matched_val = NULL;
+
+ ret = ldb_msg_find_val_schema(ldb, a, el,
+ &el->values[j],
+ &matched_val);
+ if (ret != LDB_SUCCESS) {
+ goto done;
+ }
+
+ if (matched_val == NULL) {
+ /*
+ * Something went completely wrong
+ * This must find the value itself!!!
+ */
+ ret = ldb_operr(ldb);
+ goto done;
+ }
+
+ if (matched_val != &el->values[j]) {
ldb_asprintf_errstring(ldb,
"attribute '%s': value #%u on '%s' provided more than once",
el->name, j, ldb_dn_get_linearized(msg2->dn));