ldb_tdb: Read from @INDEXLIST or an override if we are using a GUID index
authorAndrew Bartlett <abartlet@samba.org>
Tue, 15 Aug 2017 03:57:57 +0000 (15:57 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 22 Sep 2017 19:20:23 +0000 (21:20 +0200)
This allows all the previous patches to be enabled.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
lib/ldb/common/ldb_attributes.c
lib/ldb/include/ldb_module.h
lib/ldb/include/ldb_private.h
lib/ldb/ldb_tdb/ldb_cache.c

index 98ec5a409ba0eeabc57a0f0484b34931936f9f58..32f25fd0fe89616068feb325e1c15e4ae36e6824 100644 (file)
@@ -395,3 +395,17 @@ void ldb_schema_set_override_indexlist(struct ldb_context *ldb,
        ldb->schema.index_handler_override = true;
        ldb->schema.one_level_indexes = one_level_indexes;
 }
+
+/*
+ * set that the GUID index mode is in operation
+ *
+ * The caller must ensure the supplied strings do not go out of
+ * scope (they are typically constant memory).
+ */
+void ldb_schema_set_override_GUID_index(struct ldb_context *ldb,
+                                       const char *GUID_index_attribute,
+                                       const char *GUID_index_dn_component)
+{
+       ldb->schema.GUID_index_attribute = GUID_index_attribute;
+       ldb->schema.GUID_index_dn_component = GUID_index_dn_component;
+}
index 71b407496f062d03f226df9f156d98357b0382ef..ffa6c2eedb82c81d7474382780f2e9e8e97c0387 100644 (file)
@@ -183,6 +183,22 @@ void ldb_schema_attribute_set_override_handler(struct ldb_context *ldb,
 void ldb_schema_set_override_indexlist(struct ldb_context *ldb,
                                       bool one_level_indexes);
 
+/**
+
+  \param ldb The ldb context
+  \param GUID_index_attribute The globally attribute (eg objectGUID)
+         on each entry
+  \param GUID_index_attribute The DN component matching the
+         globally attribute on each entry (eg GUID)
+
+ The caller must ensure the supplied strings do not go out of
+ scope (they are typically constant memory).
+
+*/
+void ldb_schema_set_override_GUID_index(struct ldb_context *ldb,
+                                       const char *GUID_index_attribute,
+                                       const char *GUID_index_dn_component);
+
 /* A useful function to build comparison functions with */
 int ldb_any_comparison(struct ldb_context *ldb, void *mem_ctx, 
                       ldb_attr_handler_t canonicalise_fn, 
index ab215411a9a40c1ff3aac4d4bfb0824ad0ca741c..f999f7530bf1c44a3a5afdad63a269af55841124 100644 (file)
@@ -98,6 +98,9 @@ struct ldb_schema {
         */
        bool index_handler_override;
        bool one_level_indexes;
+
+       const char *GUID_index_attribute;
+       const char *GUID_index_dn_component;
 };
 
 /*
index 137ddf97fe82102edbf709427eba930d2f609f52..7bf5f156b459845b344a80154b98ff2cd2d9224e 100644 (file)
@@ -243,6 +243,10 @@ static int ltdb_index_load(struct ldb_module *module,
                 */
                ltdb->cache->attribute_indexes = true;
                ltdb->cache->one_level_indexes = ldb->schema.one_level_indexes;
+               ltdb->cache->GUID_index_attribute
+                       = ldb->schema.GUID_index_attribute;
+               ltdb->cache->GUID_index_dn_component
+                       = ldb->schema.GUID_index_dn_component;
                return 0;
        }
 
@@ -276,6 +280,12 @@ static int ltdb_index_load(struct ldb_module *module,
        if (ldb_msg_find_element(ltdb->cache->indexlist, LTDB_IDXATTR) != NULL) {
                ltdb->cache->attribute_indexes = true;
        }
+       ltdb->cache->GUID_index_attribute
+               = ldb_msg_find_attr_as_string(ltdb->cache->indexlist,
+                                             LTDB_IDXGUID, NULL);
+       ltdb->cache->GUID_index_dn_component
+               = ldb_msg_find_attr_as_string(ltdb->cache->indexlist,
+                                             LTDB_IDX_DN_GUID, NULL);
 
        return 0;
 }