diff options
author | Eduardo Lima <eduardoll@gmail.com> | 2010-03-10 16:21:29 -0300 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-03-12 16:31:20 +1100 |
commit | 7b20ad99d679de92a13652224fb33b4a0a0a7b35 (patch) | |
tree | f69b4f906fed60ed438d7c69c9d02879ed265344 /source4 | |
parent | ca67768b66758cadcc0e5e2f7544698b41c8f8ba (diff) | |
download | samba-7b20ad99d679de92a13652224fb33b4a0a0a7b35.tar.gz samba-7b20ad99d679de92a13652224fb33b4a0a0a7b35.tar.bz2 samba-7b20ad99d679de92a13652224fb33b4a0a0a7b35.zip |
s4-drs: check if an optional feature is enabled
Diffstat (limited to 'source4')
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/util.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/util.c b/source4/dsdb/samdb/ldb_modules/util.c index d3c58568ac..8cf3335e15 100644 --- a/source4/dsdb/samdb/ldb_modules/util.c +++ b/source4/dsdb/samdb/ldb_modules/util.c @@ -432,6 +432,65 @@ int dsdb_check_single_valued_link(const struct dsdb_attribute *attr, return LDB_SUCCESS; } +int dsdb_check_optional_feature(struct ldb_module *module, struct ldb_dn *scope, + struct GUID op_feature_guid, bool *feature_enabled) +{ + TALLOC_CTX *tmp_ctx; + struct ldb_context *ldb = ldb_module_get_ctx(module); + struct ldb_result *res; + struct ldb_dn *search_dn; + struct GUID search_guid; + const char *attrs[] = {"msDS-EnabledFeature", NULL}; + int ret; + int i; + struct ldb_message_element *el; + + *feature_enabled = false; + + tmp_ctx = talloc_new(ldb); + + ret = ldb_search(ldb, tmp_ctx, &res, + scope, LDB_SCOPE_BASE, attrs, + NULL); + if (ret != LDB_SUCCESS) { + ldb_asprintf_errstring(ldb, + "Could no find the scope object - dn: %s\n", + ldb_dn_get_linearized(scope)); + talloc_free(tmp_ctx); + return LDB_ERR_OPERATIONS_ERROR; + } + if (res->msgs[0]->num_elements > 0) { + + el = ldb_msg_find_element(res->msgs[0],"msDS-EnabledFeature"); + + attrs[0] = "msDS-OptionalFeatureGUID"; + + for (i=0; i<el->num_values; i++) { + search_dn = ldb_dn_from_ldb_val(tmp_ctx, ldb, &el->values[i]); + + ret = ldb_search(ldb, tmp_ctx, &res, + search_dn, LDB_SCOPE_BASE, attrs, + NULL); + if (ret != LDB_SUCCESS) { + ldb_asprintf_errstring(ldb, + "Could no find object dn: %s\n", + ldb_dn_get_linearized(search_dn)); + talloc_free(tmp_ctx); + return LDB_ERR_OPERATIONS_ERROR; + } + + search_guid = samdb_result_guid(res->msgs[0], "msDS-OptionalFeatureGUID"); + + if (GUID_compare(&search_guid, &op_feature_guid) == 0){ + *feature_enabled = true; + break; + } + } + } + talloc_free(tmp_ctx); + return LDB_SUCCESS; +} + /* find a 'reference' DN that points at another object |