This section demonstrates how to create an entry in the directory. Create a new entry by allocating space, and creating a completely new entry. Alternatively, create a new entry by duplicating an existing entry and modifying its values.
Create a completely new entry by using slapi_entry_alloc() to allocate the memory that is required, as shown in the following example.
#include "slapi-plugin.h"
int
test_ldif()
{
Slapi_Entry * entry = NULL; /* Entry to hold LDIF */
/* Allocate the Slapi_Entry structure. */
entry = slapi_entry_alloc();
/* Add code that fills the Slapi_Entry structure. */
/* Add code that uses the Slapi_Entry structure. */
/* Release memory allocated for the entry. */
slapi_entry_free(entry);
return (0);
}
Create a copy of an entry with slapi_entry_dup().