dn is freed when slapi_entry_free() is called.
A copy of dn should be passed, for example:
char *dn = slapi_ch_strdup(some_dn); slapi_entry_set_dn(e, dn);
The old dn is freed as a result of this call. Do not pass in a NULL value.