diff options
-rw-r--r-- | src/back-sch.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/back-sch.c b/src/back-sch.c index 49e1dd5..02bbdae 100644 --- a/src/back-sch.c +++ b/src/back-sch.c @@ -26,6 +26,7 @@ #include <sys/types.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <unistd.h> #ifdef HAVE_DIRSRV_SLAPI_PLUGIN_H @@ -222,6 +223,9 @@ backend_set_entry(Slapi_Entry *e, struct backend_set_data *data) Slapi_DN *e_dn, *sdn; Slapi_RDN *srdn; Slapi_Value *value; + struct tm nowtm; + time_t nowt; + char now[4 + 2 + 2 + 2 + 2 + 2 + 2]; /* YYYYMMDDHHMMSSZ\0 */ plugin_id = data->common.state->plugin_desc->spd_id; e_dn = slapi_entry_get_sdn(e); @@ -248,6 +252,23 @@ backend_set_entry(Slapi_Entry *e, struct backend_set_data *data) slapi_entry_set_sdn(entry, sdn); slapi_sdn_free(&sdn); slapi_ch_free((void **) &dn); + /* Set operational attributes. Do it first so that if users of the + * plugin want to override the values using the configuration, they + * can. */ + nowt = time(NULL); + if (gmtime_r(&nowt, &nowtm) == &nowtm) { + sprintf(now, "%04d%02d%02d%02d%02d%02dZ", + nowtm.tm_year + 1900, nowtm.tm_mon + 1, nowtm.tm_mday, + nowtm.tm_hour, nowtm.tm_min, nowtm.tm_sec); + slapi_entry_add_string(entry, "createTimestamp", now); + slapi_entry_add_string(entry, "modifyTimestamp", now); + } + slapi_entry_add_string(entry, "creatorsName", + data->common.state->plugin_base); + slapi_entry_add_string(entry, "modifiersName", + data->common.state->plugin_base); + slapi_entry_add_string(entry, "entryDN", + slapi_entry_get_dn_const(entry)); /* Iterate through the set of attributes. */ if (data->attribute_format != NULL) { value = slapi_value_new(); |