This section demonstrates how to check that an entry is valid with respect to the directory schema known to Directory Server. Verify schema compliance for an entry with slapi_entry_check(). The two arguments of the function are a pointer to a parameter block and a pointer to the entry, as shown in the following example.
#include "slapi-plugin.h" int test_create_entry() { Slapi_Entry * entry = NULL; /* Original entry */ Slapi_Entry * ecopy = NULL; /* Copy entry */ entry = slapi_entry_alloc(); /* Add code to fill the entry, setting the DN and attributes. */ ecopy = slapi_entry_dup(entry); slapi_entry_set_dn(ecopy, slapi_ch_strdup("dc=example,dc=org")); slapi_entry_add_string(ecopy, "description", "A copy of the orig."); /* Does the resulting copy comply with the schema? */ if (slapi_entry_schema_check(NULL, ecopy) == 0) { /* Resulting entry does comply. */ ; } else { /* Resulting entry does not comply. */ ; } slapi_entry_free(entry); slapi_entry_free(ecopy); return (0); }
Notice that the parameter block pointer argument is NULL. Leave the parameter block pointer argument NULL in most cases. When the plug-in is used in a replicated environment, you can use the argument to prevent schema compliance verification for replicated operations.