dsdb: Set that Samba uses the GUID index in LDB
authorAndrew Bartlett <abartlet@samba.org>
Tue, 15 Aug 2017 03:58:57 +0000 (15:58 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 23 Sep 2017 03:26:15 +0000 (05:26 +0200)
This is optional, but only to aid the downgrade script (and in case
there is some major issue found with it).  We don't support that mode,
as that would require us to test and maintain multiple code paths and
not optimise queries to be GUID centric.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/dsdb/schema/schema_set.c

index 8141e323e50db164e7671331f28cc17f0e0cc323..23d881f0bdb8be629a5967ad130973a80bd4ae54 100644 (file)
@@ -69,9 +69,16 @@ int dsdb_schema_set_indices_and_attributes(struct ldb_context *ldb,
        struct ldb_message *msg;
        struct ldb_message *msg_idx;
 
+       struct loadparm_context *lp_ctx =
+               talloc_get_type(ldb_get_opaque(ldb, "loadparm"),
+                               struct loadparm_context);
        /* setup our own attribute name to schema handler */
        ldb_schema_attribute_set_override_handler(ldb, dsdb_attribute_handler_override, schema);
        ldb_schema_set_override_indexlist(ldb, true);
+       if (lp_ctx == NULL ||
+           lpcfg_parm_bool(lp_ctx, NULL, "dsdb", "guid index", true)) {
+               ldb_schema_set_override_GUID_index(ldb, "objectGUID", "GUID");
+       }
 
        if (!write_indices_and_attributes) {
                return ret;
@@ -108,6 +115,18 @@ int dsdb_schema_set_indices_and_attributes(struct ldb_context *ldb,
                goto op_error;
        }
 
+       if (lp_ctx == NULL ||
+           lpcfg_parm_bool(lp_ctx, NULL, "dsdb", "guid index", true)) {
+               ret = ldb_msg_add_string(msg_idx, "@IDXGUID", "objectGUID");
+               if (ret != LDB_SUCCESS) {
+                       goto op_error;
+               }
+
+               ret = ldb_msg_add_string(msg_idx, "@IDX_DN_GUID", "GUID");
+               if (ret != LDB_SUCCESS) {
+                       goto op_error;
+               }
+       }
 
        ret = ldb_msg_add_string(msg_idx, "@IDXVERSION", SAMDB_INDEXING_VERSION);
        if (ret != LDB_SUCCESS) {