summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-09-04 18:47:00 -0400
committerNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-09-04 18:47:00 -0400
commit9fadfc240d5a66379576d54c9e14cc8c8148b2f2 (patch)
treed73a30e566fd148988aa3c7ddfc9b71fc9f1ccf6 /src
parent52841f970eaa4a6589cba6f0be978d9724ba9dbf (diff)
downloadslapi-nis-9fadfc240d5a66379576d54c9e14cc8c8148b2f2.tar.gz
slapi-nis-9fadfc240d5a66379576d54c9e14cc8c8148b2f2.tar.xz
slapi-nis-9fadfc240d5a66379576d54c9e14cc8c8148b2f2.zip
- populate the operational attributes when we synthesize an entry
createTimestamp (now) modifyTimestamp (now) creatorsName (the plugin) modifiersName (the plugin) entryDN (the new entry)
Diffstat (limited to 'src')
-rw-r--r--src/back-sch.c21
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();