Skip to content
Snippets Groups Projects
Commit b81122d4 authored by Jong Hyuk Choi's avatar Jong Hyuk Choi
Browse files

Slapadd is changed to include Operational Attributes (entryUUID, entryCSN,

creatorsName, modifiersName, createTimestamp, modifyTimestamp) when it adds
from ldif file. Month field in time format in entryCSN is changed to 1~12.
parent 65760c06
No related branches found
No related tags found
No related merge requests found
......@@ -54,7 +54,7 @@ lutil_csnstr(char *buf, size_t len, unsigned int replica, unsigned int mod)
ltm = gmtime( &t );
n = snprintf( buf, len, "%4d%02d%02d%02d:%02d:%02dZ#0x%04x#%d#%04x",
ltm->tm_year + 1900, ltm->tm_mon, ltm->tm_mday, ltm->tm_hour,
ltm->tm_year + 1900, ltm->tm_mon + 1, ltm->tm_mday, ltm->tm_hour,
ltm->tm_min, ltm->tm_sec, op, replica, mod );
if( n < 0 ) return 0;
......
......@@ -31,6 +31,10 @@ main( int argc, char **argv )
char textbuf[SLAP_TEXT_BUFLEN] = { '\0' };
size_t textlen = sizeof textbuf;
struct berval name, timestamp, csn;
char timebuf[22];
char csnbuf[64];
#ifdef NEW_LOGGING
lutil_log_initialize(argc, argv );
#endif
......@@ -137,6 +141,27 @@ main( int argc, char **argv )
}
}
if ( SLAP_LASTMOD(be) ) {
struct tm *ltm;
time_t now = slap_get_time();
ltm = gmtime(&now);
lutil_gentime( timebuf, sizeof(timebuf), ltm );
csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), 0, 0 );
csn.bv_val = csnbuf;
timestamp.bv_val = timebuf;
timestamp.bv_len = strlen(timebuf);
if ( be->be_rootndn.bv_len == 0 ) {
name.bv_val = SLAPD_ANONYMOUS;
name.bv_len = sizeof(SLAPD_ANONYMOUS) - 1;
} else {
name = be->be_rootndn;
}
}
if( global_schemacheck ) {
/* check schema */
......@@ -152,6 +177,42 @@ main( int argc, char **argv )
}
}
if ( SLAP_LASTMOD(be) ) {
char uuidbuf[40];
struct berval vals[2];
vals[0].bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
vals[0].bv_val = uuidbuf;
vals[1].bv_len = 0;
vals[1].bv_val = NULL;
attr_merge( e, slap_schema.si_ad_entryUUID, vals );
ber_dupbv( &vals[0], &name );
vals[1].bv_len = 0;
vals[1].bv_val = NULL;
attr_merge( e, slap_schema.si_ad_creatorsName, vals);
ber_dupbv( &vals[0], &name );
vals[1].bv_len = 0;
vals[1].bv_val = NULL;
attr_merge( e, slap_schema.si_ad_modifiersName, vals);
ber_dupbv( &vals[0], &timestamp );
vals[1].bv_len = 0;
vals[1].bv_val = NULL;
attr_merge( e, slap_schema.si_ad_createTimestamp, vals );
ber_dupbv( &vals[0], &timestamp );
vals[1].bv_len = 0;
vals[1].bv_val = NULL;
attr_merge( e, slap_schema.si_ad_modifyTimestamp, vals );
ber_dupbv( &vals[0], &csn );
vals[1].bv_len = 0;
vals[1].bv_val = NULL;
attr_merge( e, slap_schema.si_ad_entryCSN, vals );
}
if (!dryrun) {
ID id = be->be_entry_put( be, e, &bvtext );
if( id == NOID ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment