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.
This commit is contained in:
Jong Hyuk Choi 2002-08-21 00:11:32 +00:00
parent 65760c064e
commit b81122d441
2 changed files with 62 additions and 1 deletions

View File

@ -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;

View File

@ -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 ) {