s4-ldb: added an optional operator_fn in the schema syntax
[ira/wip.git] / source4 / lib / ldb / modules / rdn_name.c
index 5dc122f254a8e8ac9d9a64fb6ed79e1c7c0ab72f..a0867c0f51d33501fbb335d908ab481453f7231e 100644 (file)
@@ -147,9 +147,16 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
                }
                /* normalise attribute value */
                for (i = 0; i < attribute->num_values; i++) {
-                       ret = a->syntax->comparison_fn(ldb, msg,
-                                       &rdn_val, &attribute->values[i]);
-                       if (ret == 0) {
+                       bool matched;
+                       if (a->syntax->operator_fn) {
+                               ret = a->syntax->operator_fn(ldb, LDB_OP_EQUALITY, a,
+                                                            &rdn_val, &attribute->values[i], &matched);
+                               if (ret != LDB_SUCCESS) return ret;
+                       } else {
+                               matched = (a->syntax->comparison_fn(ldb, msg,
+                                                                   &rdn_val, &attribute->values[i]) == 0);
+                       }
+                       if (matched) {
                                /* overwrite so it matches in case */
                                attribute->values[i] = rdn_val;
                                break;