summaryrefslogtreecommitdiff
path: root/source4/dsdb/samdb/ldb_modules
diff options
context:
space:
mode:
Diffstat (limited to 'source4/dsdb/samdb/ldb_modules')
-rw-r--r--source4/dsdb/samdb/ldb_modules/repl_meta_data.c31
-rw-r--r--source4/dsdb/samdb/ldb_modules/util.c47
2 files changed, 56 insertions, 22 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
index 578ffe8a2b5..754f909467a 100644
--- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
+++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
@@ -325,37 +325,24 @@ static int replmd_init(struct ldb_module *module)
{
struct replmd_private *replmd_private;
struct ldb_context *ldb = ldb_module_get_ctx(module);
- static const char *samba_dsdb_attrs[] = { SAMBA_COMPATIBLE_FEATURES_ATTR, NULL };
- struct ldb_dn *samba_dsdb_dn;
- struct ldb_result *res;
int ret;
- TALLOC_CTX *frame = talloc_stackframe();
+
replmd_private = talloc_zero(module, struct replmd_private);
if (replmd_private == NULL) {
ldb_oom(ldb);
- TALLOC_FREE(frame);
return LDB_ERR_OPERATIONS_ERROR;
}
- ldb_module_set_private(module, replmd_private);
-
- replmd_private->schema_dn = ldb_get_schema_basedn(ldb);
-
- samba_dsdb_dn = ldb_dn_new(frame, ldb, "@SAMBA_DSDB");
- if (!samba_dsdb_dn) {
- TALLOC_FREE(frame);
- return ldb_oom(ldb);
- }
- ret = dsdb_module_search_dn(module, frame, &res, samba_dsdb_dn,
- samba_dsdb_attrs, DSDB_FLAG_NEXT_MODULE, NULL);
- if (ret == LDB_SUCCESS) {
- replmd_private->sorted_links
- = ldb_msg_check_string_attribute(res->msgs[0],
- SAMBA_COMPATIBLE_FEATURES_ATTR,
- SAMBA_SORTED_LINKS_FEATURE);
+ ret = dsdb_check_samba_compatible_feature(module,
+ SAMBA_SORTED_LINKS_FEATURE,
+ &replmd_private->sorted_links);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(replmd_private);
+ return ret;
}
- TALLOC_FREE(frame);
+ replmd_private->schema_dn = ldb_get_schema_basedn(ldb);
+ ldb_module_set_private(module, replmd_private);
return ldb_next_init(module);
}
diff --git a/source4/dsdb/samdb/ldb_modules/util.c b/source4/dsdb/samdb/ldb_modules/util.c
index ba1cfffe574..20c854f0b9a 100644
--- a/source4/dsdb/samdb/ldb_modules/util.c
+++ b/source4/dsdb/samdb/ldb_modules/util.c
@@ -681,6 +681,53 @@ int dsdb_check_single_valued_link(const struct dsdb_attribute *attr,
return LDB_SUCCESS;
}
+
+int dsdb_check_samba_compatible_feature(struct ldb_module *module,
+ const char *feature,
+ bool *found)
+{
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
+ struct ldb_result *res;
+ static const char *samba_dsdb_attrs[] = {
+ SAMBA_COMPATIBLE_FEATURES_ATTR,
+ NULL
+ };
+ int ret;
+ struct ldb_dn *samba_dsdb_dn = NULL;
+ TALLOC_CTX *tmp_ctx = talloc_new(ldb);
+ if (tmp_ctx == NULL) {
+ *found = false;
+ return ldb_oom(ldb);
+ }
+ *found = false;
+
+ samba_dsdb_dn = ldb_dn_new(tmp_ctx, ldb, "@SAMBA_DSDB");
+ if (samba_dsdb_dn == NULL) {
+ TALLOC_FREE(tmp_ctx);
+ return ldb_oom(ldb);
+ }
+
+ ret = dsdb_module_search_dn(module,
+ tmp_ctx,
+ &res,
+ samba_dsdb_dn,
+ samba_dsdb_attrs,
+ DSDB_FLAG_NEXT_MODULE,
+ NULL);
+ if (ret == LDB_SUCCESS) {
+ *found = ldb_msg_check_string_attribute(
+ res->msgs[0],
+ SAMBA_COMPATIBLE_FEATURES_ATTR,
+ feature);
+ } else if (ret == LDB_ERR_NO_SUCH_OBJECT) {
+ /* it is not an error not to find it */
+ ret = LDB_SUCCESS;
+ }
+ TALLOC_FREE(tmp_ctx);
+ return ret;
+}
+
+
/*
check if an optional feature is enabled on our own NTDS DN