From 0376d056e58d76b7792a5512d84c07f703838b4d Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Thu, 18 Jun 2009 11:05:45 +0200 Subject: Correct handling of 32-bit integer attributes in SAMBA 4 - LDB handles now all 32-bit integer attributes correctly (also with overflows) according to the schema - LDAP backends handle the attributes "groupType", "userAccountControl" and "sAMAccountType" correctly. This handling doesn't yet use the schema but the conversion file "simple_ldap.map.c" which contains them hardcoded. Did also a refactoring of the conversion function there. - Bug #6136 should be gone --- source4/dsdb/samdb/ldb_modules/simple_ldap_map.c | 39 ++++++++++++++++-------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'source4/dsdb/samdb/ldb_modules') diff --git a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c index 948241b094..0a6c350a3b 100644 --- a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c +++ b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c @@ -146,19 +146,10 @@ static struct ldb_val objectCategory_always_dn(struct ldb_module *module, TALLOC static struct ldb_val normalise_to_signed32(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val) { - long long int signed_ll = strtoll((const char *)val->data, NULL, 10); - if (signed_ll >= 0x80000000LL) { - union { - int32_t signed_int; - uint32_t unsigned_int; - } u = { - .unsigned_int = strtoul((const char *)val->data, NULL, 10) - }; - - struct ldb_val out = data_blob_string_const(talloc_asprintf(ctx, "%d", u.signed_int)); - return out; - } - return val_copy(module, ctx, val); + struct ldb_val out; + int32_t i = (int32_t) strtol((char *)val->data, NULL, 0); + out = data_blob_string_const(talloc_asprintf(ctx, "%d", i)); + return out; } static struct ldb_val usn_to_entryCSN(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val) @@ -358,6 +349,17 @@ static const struct ldb_map_attribute entryuuid_attributes[] = }, } }, + { + .local_name = "userAccountControl", + .type = MAP_CONVERT, + .u = { + .convert = { + .remote_name = "userAccountControl", + .convert_local = normalise_to_signed32, + .convert_remote = val_copy, + }, + } + }, { .local_name = "sAMAccountType", .type = MAP_CONVERT, @@ -499,6 +501,17 @@ static const struct ldb_map_attribute nsuniqueid_attributes[] = }, } }, + { + .local_name = "userAccountControl", + .type = MAP_CONVERT, + .u = { + .convert = { + .remote_name = "userAccountControl", + .convert_local = normalise_to_signed32, + .convert_remote = val_copy, + }, + } + }, { .local_name = "sAMAccountType", .type = MAP_CONVERT, -- cgit