r12408: as we always add the destinguishedName as autogenerated value,
authorStefan Metzmacher <metze@samba.org>
Wed, 21 Dec 2005 20:25:43 +0000 (20:25 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:47:34 +0000 (13:47 -0500)
don't store it on disk, as this would cause confusing results

metze
(This used to be commit c3d3309ba1567a4363c7c0235842833b5e2b6771)

source4/lib/ldb/ldb_tdb/ldb_pack.c

index bf57aa904ca3158dc78897491b08a1300f88b9d8..b037fe272a64dfc2e8c20ec0bf91c5c078b93ab6 100644 (file)
@@ -59,6 +59,17 @@ static unsigned int pull_uint32(uint8_t *p, int ofs)
        return p[0] | (p[1]<<8) | (p[2]<<16) | (p[3]<<24);
 }
 
+static int attribute_storable_values(const struct ldb_message_element *el)
+{
+       if (el->num_values == 0) return 0;
+
+       if (ldb_attr_cmp(el->name, "dn") == 0) return 0;
+
+       if (ldb_attr_cmp(el->name, "distinguishedName") == 0) return 0;
+
+       return el->num_values;
+}
+
 /*
   pack a ldb message into a linear buffer in a TDB_DATA
 
@@ -84,21 +95,18 @@ int ltdb_pack_data(struct ldb_module *module,
                return -1;
        }
 
-       for (i=0;i<message->num_elements;i++) {
-               if (message->elements[i].num_values != 0) {
-                       real_elements++;
-               }
-       }
-
        /* work out how big it needs to be */
        size = 8;
 
        size += 1 + strlen(dn);
 
        for (i=0;i<message->num_elements;i++) {
-               if (message->elements[i].num_values == 0) {
+               if (attribute_storable_values(&message->elements[i]) == 0) {
                        continue;
                }
+
+               real_elements++;
+
                size += 1 + strlen(message->elements[i].name) + 4;
                for (j=0;j<message->elements[i].num_values;j++) {
                        size += 4 + message->elements[i].values[j].length + 1;
@@ -126,7 +134,7 @@ int ltdb_pack_data(struct ldb_module *module,
        p += len + 1;
        
        for (i=0;i<message->num_elements;i++) {
-               if (message->elements[i].num_values == 0) {
+               if (attribute_storable_values(&message->elements[i]) == 0) {
                        continue;
                }
                len = strlen(message->elements[i].name);