From 014fca10697c80d49d2c3438089935c63f445644 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Jul 2011 13:26:48 +1000 Subject: dsdb: fixed special case of zero NTTIME we can't convert 0 NTTIME via a unix time_t Pair-Programmed-With: Andrew Bartlett --- source4/dsdb/schema/schema_syntax.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source4/dsdb/schema/schema_syntax.c b/source4/dsdb/schema/schema_syntax.c index a93cdfaaa9..d443c009af 100644 --- a/source4/dsdb/schema/schema_syntax.c +++ b/source4/dsdb/schema/schema_syntax.c @@ -554,6 +554,11 @@ static WERROR dsdb_syntax_NTTIME_UTC_drsuapi_to_ldb(const struct dsdb_syntax_ctx } v = BVAL(in->value_ctr.values[i].blob->data, 0); + if (v == 0) { + /* special case for 1601 zero timestamp */ + out->values[i] = data_blob_string_const("16010101000000.0Z"); + continue; + } v *= 10000000; t = nt_time_to_unix(v); @@ -607,6 +612,11 @@ static WERROR dsdb_syntax_NTTIME_UTC_ldb_to_drsuapi(const struct dsdb_syntax_ctx blobs[i] = data_blob_talloc(blobs, NULL, 8); W_ERROR_HAVE_NO_MEMORY(blobs[i].data); + if (ldb_val_string_cmp("16010101000000.0Z", &in->values[i]) == 0) { + SBVALS(blobs[i].data, 0, 0); + continue; + } + t = ldb_string_utc_to_time((const char *)in->values[i].data); unix_to_nt_time(&v, t); v /= 10000000; @@ -693,6 +703,11 @@ static WERROR dsdb_syntax_NTTIME_drsuapi_to_ldb(const struct dsdb_syntax_ctx *ct } v = BVAL(in->value_ctr.values[i].blob->data, 0); + if (v == 0) { + /* special case for 1601 zero timestamp */ + out->values[i] = data_blob_string_const("16010101000000.0Z"); + continue; + } v *= 10000000; t = nt_time_to_unix(v); @@ -739,6 +754,11 @@ static WERROR dsdb_syntax_NTTIME_ldb_to_drsuapi(const struct dsdb_syntax_ctx *ct blobs[i] = data_blob_talloc(blobs, NULL, 8); W_ERROR_HAVE_NO_MEMORY(blobs[i].data); + if (ldb_val_string_cmp("16010101000000.0Z", &in->values[i]) == 0) { + SBVALS(blobs[i].data, 0, 0); + continue; + } + ret = ldb_val_to_time(&in->values[i], &t); if (ret != LDB_SUCCESS) { return WERR_DS_INVALID_ATTRIBUTE_SYNTAX; -- cgit