Fix entryCSN format
authorHoward Chu <hyc@symas.com>
Thu, 19 Sep 2013 17:41:02 +0000 (10:41 -0700)
committerNadezhda Ivanova <nivanova@symas.com>
Tue, 24 Sep 2013 03:42:18 +0000 (20:42 -0700)
Signed-off-by: Howard Chu <hyc@symas.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Nadezhda Ivanova <nivanova@symas.com>
source4/dsdb/samdb/ldb_modules/simple_ldap_map.c

index 64dd8635085ec3f49e03c8d88364b18893e0edbb..b5041e37bcffd3b10c05583caa078c62127abe2a 100644 (file)
@@ -176,7 +176,13 @@ static struct ldb_val usn_to_entryCSN(struct ldb_module *module, TALLOC_CTX *ctx
        struct ldb_val out;
        unsigned long long usn = strtoull((const char *)val->data, NULL, 10);
        time_t t = (usn >> 24);
-       out = data_blob_string_const(talloc_asprintf(ctx, "%s#%06x#00#000000", ldb_timestring(ctx, t), (unsigned int)(usn & 0xFFFFFF)));
+       struct tm *tm = gmtime(&t);
+       /* CSN timestamp is YYYYMMDDhhmmss.ssssssZ */
+       out = data_blob_string_const(talloc_asprintf(ctx,
+               "%04u%02u%02u%02u%02u%02u.000000Z#%06x#000#000000",
+               tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
+               tm->tm_hour, tm->tm_min, tm->tm_sec,
+               (unsigned int)(usn & 0xFFFFFF)));
        return out;
 }