r18367: When converting to entryUUID, ensure we don't double-convert a
authorAndrew Bartlett <abartlet@samba.org>
Mon, 11 Sep 2006 07:50:49 +0000 (07:50 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:18:19 +0000 (14:18 -0500)
string-format GUID.

Andrew Bartlett
(This used to be commit 11cc6408c93f46f4d9ae7ae0ee18dac836fe270d)

source4/dsdb/samdb/ldb_modules/entryUUID.c

index d6f4b10d76cd5a9df60a1ba2ef4aa8e0cf5e2e0c..29e80ff003470b9fd37da58bf570c5a4f9fca4c6 100644 (file)
@@ -58,24 +58,27 @@ static struct ldb_val encode_guid(struct ldb_module *module, TALLOC_CTX *ctx, co
        return out;
 }
 
-static struct ldb_val decode_guid(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
+static struct ldb_val guid_always_string(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
 {
        struct GUID *guid;
        NTSTATUS status;
        struct ldb_val out = data_blob(NULL, 0);
-       
-       guid = talloc(ctx, struct GUID);
-       if (guid == NULL) {
-               return out;
-       }
-       status = ndr_pull_struct_blob(val, guid, guid, 
-                                     (ndr_pull_flags_fn_t)ndr_pull_GUID);
-       if (!NT_STATUS_IS_OK(status)) {
+       if (val->length >= 32 && val->data[val->length] == '\0') {
+               ldb_handler_copy(module->ldb, ctx, val, &out);
+       } else {
+               guid = talloc(ctx, struct GUID);
+               if (guid == NULL) {
+                       return out;
+               }
+               status = ndr_pull_struct_blob(val, guid, guid, 
+                                             (ndr_pull_flags_fn_t)ndr_pull_GUID);
+               if (!NT_STATUS_IS_OK(status)) {
+                       talloc_free(guid);
+                       return out;
+               }
+               out = data_blob_string_const(GUID_string(ctx, guid));
                talloc_free(guid);
-               return out;
        }
-       out = data_blob_string_const(GUID_string(ctx, guid));
-       talloc_free(guid);
        return out;
 }
 
@@ -179,7 +182,7 @@ const struct ldb_map_attribute entryUUID_attributes[] =
                .u = {
                        .convert = {
                                .remote_name = "entryUUID", 
-                               .convert_local = decode_guid,
+                               .convert_local = guid_always_string,
                                .convert_remote = encode_guid,
                        },
                },