return -1;
}
+ /* check we are not trying to delete a required attribute */
+ /* TODO: consider multivalued attrs */
+ if ((attr->flags & SCHEMA_FLAG_MOD_DELETE) != 0) {
+ ldb_debug(module->ldb, LDB_DEBUG_ERROR,
+ "Trying to delete the required attribute %s.\n",
+ attr->name);
+
+ data->error_string = "Objectclass violation, a required attribute cannot be removed";
+ talloc_free(entry_structs);
+ return -1;
+ }
+
/* mark the attribute as checked */
attr->flags = SCHEMA_FLAG_CHECKED;
}
Retrieve the ldap entry and get the objectclasses,
add msg contained objectclasses if any.
Build up a list of required_attrs and optional_attrs attributes from each objectclass
- Check all required_attrs one for the defined objectclass and all its parent
- objectclasses.
- Check all other the attributes are optional_attrs or required_attrs.
+ Check all the attributes are optional_attrs or required_attrs.
Throw an error in case a check fail.
Free all structures and commit the change.
*/
+++ /dev/null
-dn: CN=Test,CN=Users,DC=schema,DC=test
-changetype: modify
-replace: description
-description: this test must not fail
-
-dn: CN=Test,CN=Users,DC=schema,DC=test
-changetype: modify
-delete: description
-# this test must not fail
-
-dn: CN=Test,CN=Users,DC=schema,DC=test
-changetype: modify
-add: description
-description: this test must not fail
-
-dn: CN=Test,CN=Users,DC=schema,DC=test
-changetype: modify
-add: foo
-foo: this test must fail
-
-dn: CN=Test,CN=Users,DC=schema,DC=test
-changetype: modify
-delete: nTSecurityDescriptor
-# this test must fail
-
--- /dev/null
+dn: CN=Test,CN=Users,DC=schema,DC=test
+changetype: modify
+replace: description
+description: this test must not fail
+
--- /dev/null
+dn: CN=Test,CN=Users,DC=schema,DC=test
+changetype: modify
+delete: description
+# this test must not fail
+
--- /dev/null
+dn: CN=Test,CN=Users,DC=schema,DC=test
+changetype: modify
+add: description
+description: this test must not fail
+
--- /dev/null
+dn: CN=Test,CN=Users,DC=schema,DC=test
+changetype: modify
+add: foo
+foo: this test must fail
+
--- /dev/null
+dn: CN=Test,CN=Users,DC=schema,DC=test
+changetype: modify
+delete: nTSecurityDescriptor
+# this test must fail
+
echo "LDB_URL: $LDB_URL"
echo "Adding schema"
-$VALGRIND bin/ldbadd tests/schema.ldif || exit 1
+$VALGRIND bin/ldbadd tests/schema-tests/schema.ldif || exit 1
echo "Adding few test elements (no failure expected here)"
-$VALGRIND bin/ldbadd tests/schema-add-test.ldif || exit 1
+$VALGRIND bin/ldbadd tests/schema-tests/schema-add-test.ldif || exit 1
echo "Modifying elements (2 failures expected here)"
-$VALGRIND bin/ldbmodify tests/schema-mod-test.ldif
+
+$VALGRIND bin/ldbmodify tests/schema-tests/schema-mod-test-1.ldif || exit 1
+$VALGRIND bin/ldbmodify tests/schema-tests/schema-mod-test-2.ldif || exit 1
+$VALGRIND bin/ldbmodify tests/schema-tests/schema-mod-test-3.ldif || exit 1
+$VALGRIND bin/ldbmodify tests/schema-tests/schema-mod-test-4.ldif
+if [ "$?" == "0" ]; then
+ echo "test failed!"
+ exit 1
+fi
+$VALGRIND bin/ldbmodify tests/schema-tests/schema-mod-test-5.ldif
+if [ "$?" == "0" ]; then
+ echo "test failed!"
+ exit 1
+fi
echo "Showing modified record"
$VALGRIND bin/ldbsearch '(cn=Test)' || exit 1