"SINGLE-VALUE )", 0,
offsetof( struct lastmod_schema_t, lms_ad_lastmodEnabled ) },
{ NULL }
+
+ /* FIXME: what about UUID of last modified entry? */
};
static int
static int
best_guess( Operation *op,
+ struct berval *bv_entryCSN, struct berval *bv_nentryCSN,
struct berval *bv_modifyTimestamp, struct berval *bv_nmodifyTimestamp,
struct berval *bv_modifiersName, struct berval *bv_nmodifiersName )
{
+ if ( bv_entryCSN ) {
+ char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
+ struct berval entryCSN;
+
+ slap_get_csn( NULL, csnbuf, sizeof(csnbuf), &entryCSN, 0 );
+
+ ber_dupbv( bv_entryCSN, &entryCSN );
+ ber_dupbv( bv_nentryCSN, &entryCSN );
+ }
+
if ( bv_modifyTimestamp ) {
struct tm *tm;
#ifdef HAVE_GMTIME_R
lastmod_info_t *lmi = (lastmod_info_t *)on->on_bi.bi_private;
Attribute *a;
Modifications *ml = NULL;
- struct berval bv_modifyTimestamp = BER_BVNULL,
+ struct berval bv_entryCSN = BER_BVNULL,
+ bv_nentryCSN = BER_BVNULL,
+ bv_modifyTimestamp = BER_BVNULL,
bv_nmodifyTimestamp = BER_BVNULL,
bv_modifiersName = BER_BVNULL,
bv_nmodifiersName = BER_BVNULL,
case LDAP_REQ_ADD:
lmt = LASTMOD_ADD;
e = op->ora_e;
- a = attr_find( e->e_attrs, slap_schema.si_ad_modifiersName );
+ a = attr_find( e->e_attrs, slap_schema.si_ad_entryCSN );
if ( a != NULL ) {
- ber_dupbv( &bv_modifiersName, &a->a_vals[0] );
- ber_dupbv( &bv_nmodifiersName, &a->a_nvals[0] );
+ ber_dupbv( &bv_entryCSN, &a->a_vals[0] );
+ if ( a->a_nvals && !BER_BVISNULL( &a->a_nvals[0] ) ) {
+ ber_dupbv( &bv_nentryCSN, &a->a_nvals[0] );
+ } else {
+ ber_dupbv( &bv_nentryCSN, &a->a_vals[0] );
+ }
}
a = attr_find( e->e_attrs, slap_schema.si_ad_modifyTimestamp );
if ( a != NULL ) {
ber_dupbv( &bv_nmodifyTimestamp, &a->a_vals[0] );
}
}
+ a = attr_find( e->e_attrs, slap_schema.si_ad_modifiersName );
+ if ( a != NULL ) {
+ ber_dupbv( &bv_modifiersName, &a->a_vals[0] );
+ ber_dupbv( &bv_nmodifiersName, &a->a_nvals[0] );
+ }
ber_dupbv( &bv_name, &e->e_name );
ber_dupbv( &bv_nname, &e->e_nname );
break;
case LDAP_REQ_DELETE:
lmt = LASTMOD_DELETE;
- best_guess( op, &bv_modifyTimestamp, &bv_nmodifyTimestamp,
+ best_guess( op, &bv_entryCSN, &bv_nentryCSN,
+ &bv_modifyTimestamp, &bv_nmodifyTimestamp,
&bv_modifiersName, &bv_nmodifiersName );
ber_dupbv( &bv_name, &op->o_req_dn );
/* actually, password change is wrapped around a backend
* call to modify, so it never shows up as an exop... */
- best_guess( op, &bv_modifyTimestamp, &bv_nmodifyTimestamp,
+ best_guess( op, &bv_entryCSN, &bv_nentryCSN,
+ &bv_modifyTimestamp, &bv_nmodifyTimestamp,
&bv_modifiersName, &bv_nmodifiersName );
ber_dupbv( &bv_name, &op->o_req_dn );
case LDAP_REQ_MODIFY:
lmt = LASTMOD_MODIFY;
+ rc = 3;
for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
if ( ad_cmp( ml->sml_desc , slap_schema.si_ad_modifiersName ) == 0 ) {
ber_dupbv( &bv_modifiersName, &ml->sml_values[0] );
ber_dupbv( &bv_nmodifiersName, &ml->sml_nvalues[0] );
- if ( !BER_BVISNULL( &bv_modifyTimestamp ) ) {
+ rc--;
+ if ( !rc ) {
+ break;
+ }
+
+ } else if ( ad_cmp( ml->sml_desc, slap_schema.si_ad_entryCSN ) == 0 ) {
+ ber_dupbv( &bv_entryCSN, &ml->sml_values[0] );
+ if ( ml->sml_nvalues && !BER_BVISNULL( &ml->sml_nvalues[0] ) ) {
+ ber_dupbv( &bv_nentryCSN, &ml->sml_nvalues[0] );
+ } else {
+ ber_dupbv( &bv_nentryCSN, &ml->sml_values[0] );
+ }
+
+ rc --;
+ if ( !rc ) {
break;
}
ber_dupbv( &bv_nmodifyTimestamp, &ml->sml_values[0] );
}
- if ( !BER_BVISNULL( &bv_modifiersName ) ) {
+ rc --;
+ if ( !rc ) {
break;
}
}
/* if rooted at global overlay, opattrs are not yet in place */
if ( BER_BVISNULL( &bv_modifiersName ) ) {
- best_guess( op, NULL, NULL, &bv_modifiersName, &bv_nmodifiersName );
+ best_guess( op, NULL, NULL, NULL, NULL, &bv_modifiersName, &bv_nmodifiersName );
+ }
+
+ if ( BER_BVISNULL( &bv_entryCSN ) ) {
+ best_guess( op, &bv_entryCSN, &bv_nentryCSN, NULL, NULL, NULL, NULL );
}
- /* if rooted at global overlay, opattrs are not yet in place */
if ( BER_BVISNULL( &bv_modifyTimestamp ) ) {
- best_guess( op, &bv_modifyTimestamp, &bv_nmodifyTimestamp, NULL, NULL );
+ best_guess( op, NULL, NULL, &bv_modifyTimestamp, &bv_nmodifyTimestamp, NULL, NULL );
}
ber_dupbv( &bv_name, &op->o_req_dn );
ber_dupbv( &bv_modifiersName, &a->a_vals[0] );
ber_dupbv( &bv_nmodifiersName, &a->a_nvals[0] );
}
+ a = attr_find( e->e_attrs, slap_schema.si_ad_entryCSN );
+ if ( a != NULL ) {
+ ber_dupbv( &bv_entryCSN, &a->a_vals[0] );
+ if ( a->a_nvals && !BER_BVISNULL( &a->a_nvals[0] ) ) {
+ ber_dupbv( &bv_nentryCSN, &a->a_nvals[0] );
+ } else {
+ ber_dupbv( &bv_nentryCSN, &a->a_vals[0] );
+ }
+ }
a = attr_find( e->e_attrs, slap_schema.si_ad_modifyTimestamp );
if ( a != NULL ) {
ber_dupbv( &bv_modifyTimestamp, &a->a_vals[0] );
/* if !bi_entry_get_rw || bi_entry_get_rw failed for any reason... */
if ( e == NULL ) {
- best_guess( op, &bv_modifyTimestamp, &bv_nmodifyTimestamp,
+ best_guess( op, &bv_entryCSN, &bv_nentryCSN,
+ &bv_modifyTimestamp, &bv_nmodifyTimestamp,
&bv_modifiersName, &bv_nmodifiersName );
}
ch_free( a->a_nvals[0].bv_val );
a->a_nvals[0] = bv_nmodifyTimestamp;
+#if 0
+ fprintf( stderr, "### entryCSN: %s %s\n", bv_nentryCSN.bv_val, bv_entryCSN.bv_val );
+#endif
+
+ a = attr_find( lmi->lmi_e->e_attrs, slap_schema.si_ad_entryCSN );
+ if ( a == NULL ) {
+ goto error_return;
+ }
+ ch_free( a->a_vals[0].bv_val );
+ a->a_vals[0] = bv_entryCSN;
+ ch_free( a->a_nvals[0].bv_val );
+ a->a_nvals[0] = bv_nentryCSN;
+
rc = 0;
error_return:;
#endif
static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
+ char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
+ struct berval entryCSN;
+
if ( !SLAP_LASTMOD( be ) ) {
fprintf( stderr, "set \"lastmod on\" to make this overlay effective\n" );
return -1;
ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
#endif
+ slap_get_csn( NULL, csnbuf, sizeof(csnbuf), &entryCSN, 0 );
+
if ( BER_BVISNULL( &lmi->lmi_rdnvalue ) ) {
ber_str2bv( "Lastmod", 0, 1, &lmi->lmi_rdnvalue );
}
"%s: %s\n"
"createTimestamp: %s\n"
"creatorsName: %s\n"
+ "entryCSN: %s\n"
"modifyTimestamp: %s\n"
"modifiersName: %s\n"
"hasSubordinates: FALSE\n",
lastmod_schema.lms_ad_lastmodEnabled->ad_cname.bv_val, lmi->lmi_enabled ? "TRUE" : "FALSE",
tmbuf,
BER_BVISNULL( &be->be_rootdn ) ? SLAPD_ANONYMOUS : be->be_rootdn.bv_val,
+ entryCSN.bv_val,
tmbuf,
BER_BVISNULL( &be->be_rootdn ) ? SLAPD_ANONYMOUS : be->be_rootdn.bv_val );