From: Andrew Bartlett Date: Fri, 3 Feb 2017 03:13:43 +0000 (+1300) Subject: schema: Set flag into @INDEXLIST to indicate we support feature flags X-Git-Tag: talloc-2.1.9~230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48da42c85f2924f4526919825bb3dec0f2259d7e;p=thirdparty%2Fsamba.git schema: Set flag into @INDEXLIST to indicate we support feature flags Because @INDEXLIST is rewritten by all Samba versions, we can detect that we have opened the database with an older version that does not support the feature flags by the absense of this in @INDEXLIST Signed-off-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/source4/dsdb/samdb/ldb_modules/samba_dsdb.c b/source4/dsdb/samdb/ldb_modules/samba_dsdb.c index 9de62f386c9..fd432e20240 100644 --- a/source4/dsdb/samdb/ldb_modules/samba_dsdb.c +++ b/source4/dsdb/samdb/ldb_modules/samba_dsdb.c @@ -235,7 +235,7 @@ static int samba_dsdb_init(struct ldb_module *module) TALLOC_CTX *tmp_ctx = talloc_new(module); struct ldb_result *res; struct ldb_message *rootdse_msg = NULL, *partition_msg; - struct ldb_dn *samba_dsdb_dn, *partition_dn; + struct ldb_dn *samba_dsdb_dn, *partition_dn, *indexlist_dn; struct ldb_module *backend_module, *module_chain; const char **final_module_list, **reverse_module_list; /* @@ -320,6 +320,7 @@ static int samba_dsdb_init(struct ldb_module *module) static const char *samba_dsdb_attrs[] = { "backendType", SAMBA_COMPATIBLE_FEATURES_ATTR, SAMBA_REQUIRED_FEATURES_ATTR, NULL }; + static const char *indexlist_attrs[] = { SAMBA_FEATURES_SUPPORTED_FLAG, NULL }; static const char *partition_attrs[] = { "ldapBackend", NULL }; const char *backendType, *backendUrl; bool use_sasl_external = false; @@ -342,6 +343,12 @@ static int samba_dsdb_init(struct ldb_module *module) return ldb_oom(ldb); } + indexlist_dn = ldb_dn_new(tmp_ctx, ldb, "@INDEXLIST"); + if (!samba_dsdb_dn) { + talloc_free(tmp_ctx); + return ldb_oom(ldb); + } + partition_dn = ldb_dn_new(tmp_ctx, ldb, DSDB_PARTITION_DN); if (!partition_dn) { talloc_free(tmp_ctx); diff --git a/source4/dsdb/samdb/samdb.h b/source4/dsdb/samdb/samdb.h index 586a3bfaf0e..3eb4a67bdfc 100644 --- a/source4/dsdb/samdb/samdb.h +++ b/source4/dsdb/samdb/samdb.h @@ -316,4 +316,5 @@ struct dsdb_extended_sec_desc_propagation_op { #define SAMBA_COMPATIBLE_FEATURES_ATTR "compatibleFeatures" #define SAMBA_REQUIRED_FEATURES_ATTR "requiredFeatures" +#define SAMBA_FEATURES_SUPPORTED_FLAG "@SAMBA_FEATURES_SUPPORTED" #endif /* __SAMDB_H__ */ diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c index 6f03046ff21..2e688d07546 100644 --- a/source4/dsdb/schema/schema_set.c +++ b/source4/dsdb/schema/schema_set.c @@ -111,6 +111,11 @@ static int dsdb_schema_set_indices_and_attributes(struct ldb_context *ldb, struc goto op_error; } + ret = ldb_msg_add_string(msg_idx, SAMBA_FEATURES_SUPPORTED_FLAG, "1"); + if (ret != LDB_SUCCESS) { + goto op_error; + } + for (attr = schema->attributes; attr; attr = attr->next) { const char *syntax = attr->syntax->ldb_syntax;