summaryrefslogtreecommitdiff
path: root/source4/lib/registry
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-06-14 13:56:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:56:41 -0500
commit0b817ae8511983825ef63d2989e937f03beb39cf (patch)
treebb3748db99e305c127cf081a854dfee29060c6d7 /source4/lib/registry
parent6c13c97ac2e17b162cc286ea251ab729c44d1a3f (diff)
downloadsamba-0b817ae8511983825ef63d2989e937f03beb39cf.tar.gz
samba-0b817ae8511983825ef63d2989e937f03beb39cf.tar.bz2
samba-0b817ae8511983825ef63d2989e937f03beb39cf.zip
r1147: Support enumerating values
(This used to be commit 3af8419fa4053a3b2887e91b4bda5c93327efad4)
Diffstat (limited to 'source4/lib/registry')
-rw-r--r--source4/lib/registry/reg_backend_ldb/reg_backend_ldb.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/source4/lib/registry/reg_backend_ldb/reg_backend_ldb.c b/source4/lib/registry/reg_backend_ldb/reg_backend_ldb.c
index 408ce52e44..9dfd3329e0 100644
--- a/source4/lib/registry/reg_backend_ldb/reg_backend_ldb.c
+++ b/source4/lib/registry/reg_backend_ldb/reg_backend_ldb.c
@@ -52,7 +52,6 @@ static char *reg_path_to_ldb(TALLOC_CTX *mem_ctx, const char *path, const char *
ret[strlen(ret)-1] = '\0';
- printf("Doing search for : %s\n", ret);
return ret;
}
@@ -82,13 +81,17 @@ static WERROR ldb_close_registry(REG_HANDLE *h)
return WERR_OK;
}
+static WERROR ldb_add_key(REG_KEY *p, const char *name, uint32_t access_mask, SEC_DESC *sec, REG_KEY **new)
+{
+ return WERR_NOT_SUPPORTED;
+}
+
static WERROR ldb_fetch_subkeys(REG_KEY *k, int *count, REG_KEY ***subkeys)
{
struct ldb_context *c = k->handle->backend_data;
char *path;
int ret, i, j;
struct ldb_message **msg;
- TALLOC_CTX *mem_ctx = talloc_init("ldb_path");
REG_KEY *key = NULL;
ret = ldb_search(c, (char *)k->backend_data, LDB_SCOPE_ONELEVEL, "(key=*)", NULL,&msg);
@@ -117,7 +120,43 @@ static WERROR ldb_fetch_subkeys(REG_KEY *k, int *count, REG_KEY ***subkeys)
*count = j;
ldb_search_free(c, msg);
- talloc_destroy(mem_ctx);
+ return WERR_OK;
+}
+
+static WERROR ldb_fetch_values(REG_KEY *k, int *count, REG_VAL ***values)
+{
+ struct ldb_context *c = k->handle->backend_data;
+ char *path;
+ int ret, i, j;
+ struct ldb_message **msg;
+ REG_KEY *key = NULL;
+
+ ret = ldb_search(c, (char *)k->backend_data, LDB_SCOPE_ONELEVEL, "(value=*)", NULL,&msg);
+
+ if(ret < 0) {
+ DEBUG(0, ("Error getting values for '%s': %s\n", k->backend_data, ldb_errstring(c)));
+ return WERR_FOOBAR;
+ }
+
+ *values = talloc_array_p(k->mem_ctx, REG_VAL *, ret);
+ j = 0;
+ for(i = 0; i < ret; i++) {
+ struct ldb_message_element *el;
+ char *name;
+ el = ldb_msg_find_element(msg[i], "key");
+
+ name = el->values[0].data;
+
+ /* Dirty hack to circumvent ldb_tdb bug */
+ if(k->backend_data && !strcmp(msg[i]->dn, (char *)k->backend_data)) continue;
+
+ (*values)[j] = reg_val_new(k, NULL);
+ (*values)[j]->backend_data = talloc_strdup((*values)[j]->mem_ctx, msg[i]->dn);
+ j++;
+ }
+ *count = j;
+
+ ldb_search_free(c, msg);
return WERR_OK;
}
@@ -125,7 +164,6 @@ static WERROR ldb_get_hive(REG_HANDLE *h, int num, REG_KEY **key)
{
if(num != 0) return WERR_NO_MORE_ITEMS;
*key = reg_key_new_abs("", h, NULL);
-// (*key)->backend_data = talloc_strdup((*key)->mem_ctx, "");
return WERR_OK;
}
@@ -167,6 +205,8 @@ static struct registry_ops reg_backend_ldb = {
.close_registry = ldb_close_registry,
.open_key = ldb_open_key,
.fetch_subkeys = ldb_fetch_subkeys,
+ .fetch_values = ldb_fetch_values,
+ .add_key = ldb_add_key,
};
NTSTATUS registry_ldb_init(void)