ldb_tdb: Load the syntax of the GUID index attr during ltdb_cache_load()
authorAndrew Bartlett <abartlet@samba.org>
Tue, 15 Aug 2017 22:42:40 +0000 (10:42 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 22 Sep 2017 19:20:22 +0000 (21:20 +0200)
This allows us to use the ldif_write function later to create a string GUID for the TDB key.

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

index f08e073af1a182d554211ff01774287d04d43a8b..137ddf97fe82102edbf709427eba930d2f609f52 100644 (file)
@@ -371,6 +371,7 @@ int ltdb_cache_load(struct ldb_module *module)
        struct ldb_dn *baseinfo_dn = NULL, *options_dn = NULL;
        uint64_t seq;
        struct ldb_message *baseinfo = NULL, *options = NULL;
+       const struct ldb_schema_attribute *a;
        int r;
 
        ldb = ldb_module_get_ctx(module);
@@ -474,6 +475,17 @@ int ltdb_cache_load(struct ldb_module *module)
                goto failed;
        }
 
+       ltdb->GUID_index_syntax = NULL;
+       if (ltdb->cache->GUID_index_attribute != NULL) {
+               /*
+                * Now the attributes are loaded, set the guid_index_syntax.
+                * This can't fail, it will return a default at worst
+                */
+               a = ldb_schema_attribute_by_name(ldb,
+                                                ltdb->cache->GUID_index_attribute);
+               ltdb->GUID_index_syntax = a->syntax;
+       }
+
 done:
        talloc_free(options);
        talloc_free(baseinfo);
index a0b5f2cc9496d34c7b3992611702b4a14be97567..17d9e6612ccf9af8bc58fcf9f573d20b8dbd0e84 100644 (file)
@@ -35,6 +35,8 @@ struct ltdb_private {
        bool warn_reindex;
 
        bool read_only;
+
+       const struct ldb_schema_syntax *GUID_index_syntax;
 };
 
 struct ltdb_context {