From e65d971e5d751769f99ae474b73ca07c41800bbe Mon Sep 17 00:00:00 2001 From: Arvid Requate Date: Thu, 18 Apr 2013 16:26:08 +0200 Subject: [PATCH] ldb: accept milliseconds in String(Generalized-Time) The Windows 2008 R2 Remote Desktop License Manager sends the "msTSExpireDate" attribute in a millisecond format (".000Z") Patch courtesy of http://www.snix.com/wiki/index.php/Samba_4 --- lib/ldb/common/ldb_msg.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ldb/common/ldb_msg.c b/lib/ldb/common/ldb_msg.c index 809e3af..4358619 100644 --- a/lib/ldb/common/ldb_msg.c +++ b/lib/ldb/common/ldb_msg.c @@ -1092,7 +1092,7 @@ int ldb_val_to_time(const struct ldb_val *v, time_t *t) { struct tm tm; - if (v == NULL || !v->data || (v->length != 17 && v->length != 13)) { + if (v == NULL || !v->data || (v->length != 19 && v->length != 17 && v->length != 13)) { return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX; } @@ -1104,6 +1104,12 @@ int ldb_val_to_time(const struct ldb_val *v, time_t *t) &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) { return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX; } + } else if (v->length == 19) { + if (sscanf((char *)v->data, "%04u%02u%02u%02u%02u%02u.000Z", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday, + &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) { + return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX; + } } else { if (sscanf((char *)v->data, "%04u%02u%02u%02u%02u%02u.0Z", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, -- 1.7.10.4